Changing date using type - xtype

I’d like to reach this URL Storico Molecular Medicine | Dati storici - Investing.com and click “scarica dati”. Before i ha to change start data of the period but it doesn’t work well, i think. Anyone can suggests the right code to modify start data?

Type and SendKeys do not work with this data control, but XClick and XType work fine. I made a short demo macro. It uses ${KEY_DEL} and ${KEY_BKSP} to clear the input fields.

Here is a screencast of it running:

And here is the code:

{
  "Name": "set date control",
  "CreationDate": "2019-6-28",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://it.investing.com/equities/molmed-historical-data",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "id=leftColumn",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "id=widgetFieldDateRange",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=/html/body",
      "Value": ""
    },
    {
      "Command": "XClick",
      "Target": "id=startDate",
      "Value": ""
    },
    {
      "Command": "XType",
      "Target": "${KEY_DEL}${KEY_DEL}${KEY_DEL}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}1/1/2019",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=/html/body",
      "Value": ""
    },
    {
      "Command": "XClick",
      "Target": "id=endDate",
      "Value": ""
    },
    {
      "Command": "XType",
      "Target": "${KEY_DEL}${KEY_DEL}${KEY_DEL}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}${KEY_BKSP}2/2/2019",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "link=Applica@POS=2",
      "Value": ""
    }
  ]
}
1 Like

admin , you are great!

Hi Everyone,

I’m fairly new into this world of coding and trying my hand at automating pulling a report from out website. However, the dates have to change dynamically to automate it as daily task when pulling the search query’s. I’ve pasted the code below for help on how to create and properly set up a dynamic date to select and pick today’s date before running a search.

I’m really not sure where to make the changes in the code so I used common sense and looked for keywords related to dates.

“Name”: “RMA_Export”,
“CreationDate”: “2021-7-1”,
“Commands”: [
{
“Command”: “open”,
“Target”: “Sign in - R1 for goTRG”,
“Value”: “”,
“Description”: “”

},
{
“Command”: “click”,
“Target”: “xpath=//[@id="MainForm"]/main/section/div[9]/div[2]/div/div/div[2]/div/div/div[2]/div[2]/div/div[5]",
“Value”: “”,
“Targets”: [
"xpath=//
[@id="MainForm"]/main/section/div[9]/div[2]/div/div/div[2]/div/div/div[2]/div[2]/div/div[5]”,
“xpath=//div[2]/div/div/div[2]/div[2]/div/div[5]”,
“css=#MainForm > main > section.filter__container > div:nth-child(9) > div:nth-child(4) > div > div:nth-child(1) > div.react-datepicker-popper > div > div > div.react-datepicker__month-container > div.react-datepicker__month > div:nth-child(1) > div.react-datepicker__day.react-datepicker__day–001.react-datepicker__day–keyboard-selected.react-datepicker__day–today”
],