Open link in new tab

same result as before, it navigated to the right spot, but then opened in the current tab.

Good to know. => So it is not a wrong Xpath or Javascript issue.

The demo account in Xero

Do you have a link for that? And once inside the web app, how do I find the right place?

We do have a training doc on Xero which might assist in this regard:

navigate through the left-hand column by clicking, you would be interested in the Xero invoices-invoice navigation and introduction to Xero-Dashboard navigation. company is called demo account, but I think you would be in it already from when you sign up.

Thanks for the test website, that helped!

I am still not sure why it happens. My guess is that somehow this table control “swallows” the CTRL key press. But I found two three (see below for 3rd) good workarounds:

  1. XClick | ... | #ctrlclick works in desktop automation mode! So you can add XDesktopAutomation | true before the XClick. But desktop automation requires the use of image or OCR input for XClick. So since you prefer to use an XPath locator, the second option is better.

  2. Send an XClick | ... | #right click to open the context menu, and then do a mouse down + enter (Xtype | ${KEY_DOWN}${KEY_ENTER} ) to select the first menu entry “Open in new tab”

Both workarounds are shown here:

{
  "Name": "xero",
  "CreationDate": "2021-10-5",
  "Commands": [
    {
      "Command": "XClick",
      "Target": "city_dpi_168.png",
      "Value": "#right",
      "Description": ""
    },
    {
      "Command": "XType",
      "Target": "${KEY_DOWN}${KEY_ENTER}",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "XDesktopAutomation",
      "Target": "true",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "XClick",
      "Target": "city_dpi_168.png",
      "Value": "#ctrlclick",
      "Description": ""
    }
  ]
}

Also, I found that the store attribute solution as suggested by @erdomay7 works as well, once you find the right xpath.

In our case we need the one with the /a at the end. It contains the href attribute:

image

So this works:

  1. extract URL with “store attribute @href
  2. Split string to get ID
  3. Combine the “View.aspx” base URL with ID
  4. Open new tab with selectWindow | Tab=Open

See here:

Macro:

{
  "Name": "storeattribute",
  "CreationDate": "2021-10-5",
  "Commands": [
    {
      "Command": "storeAttribute",
      "Target": "xpath=//tr[4]/td[4]/a@href",
      "Value": "a",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${a}",
      "Value": "blue",
      "Description": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return ${a}.split(\"=\")[1].trim();",
      "Value": "b",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${b}",
      "Value": "green",
      "Description": ""
    },
    {
      "Command": "selectWindow",
      "Target": "TAB=OPEN",
      "Value": "https://go.xero.com/AccountsReceivable/View.aspx?InvoiceID=${b}",
      "Description": ""
    }
  ]
}

busy testing this one, works best with the constantly changing variable, just having issues getting to click on the right element, seems to see the column headers ( to, due date, date etc) as the first value and stores that even though the element bayside club is the first element, but that is my problem to look into.

ok one odd thing, the code below:

Blockquote
{
“Command”: “open”,
“Target”: “Login | Xero Accounting Software”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “linkText=Due Date”,
“Value”: “”,
“Targets”: [
“linkText=Due Date”,
“xpath=//[@id="ext-gen41"]/thead/tr/td[6]/a",
“xpath=//td[6]/a”,
“css=#ext-gen41 > thead > tr > td.selected > a”
],
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “1000”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “linkText=Due”,
“Value”: “”,
“Targets”: [
“linkText=Due”,
"xpath=//
[@id="ext-gen41"]/thead/tr/td[9]/a”,
“xpath=//td[9]/a”,
“css=#ext-gen41 > thead > tr > td:nth-child(9) > a”
],
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “1000”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “type”,
“Target”: “id=sb_txtReference”,
“Value”: “CN”,
“Targets”: [
“id=sb_txtReference”,
“name=invoiceReference”,
“xpath=//[@id="sb_txtReference"]",
“xpath=//input[@id=‘sb_txtReference’]”,
“xpath=//div/input”,
“css=#sb_txtReference”
],
“Description”: “”
},
{
“Command”: “click”,
“Target”: “linkText=Search”,
“Value”: “”,
“Targets”: [
“linkText=Search”,
“id=sbSubmit_”,
"xpath=//
[@id="sbSubmit_"]”,
“xpath=//a[@id=‘sbSubmit_’]”,
“xpath=//a[2]”,
“css=#sbSubmit_”
],
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “2000”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “times”,
“Target”: “10”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “2”,
“Value”: “i”,
“Description”: “”
},
{
“Command”: “while_v2”,
“Target”: “${i}<200”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return Number (${i}) +1;”,
“Value”: “Link”,
“Description”: “reconcile”
},
{
“Command”: “storeAttribute”,
“Target”: “xpath=//tr[${i}]/td[4]/a@href”,
“Value”: “a”,
“Description”: “”
},
{
“Command”: “echo”,
“Target”: “${a}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return ${a}.split("=")[1].trim();”,
“Value”: “b”,
“Description”: “”
},
{
“Command”: “selectWindow”,
“Target”: “TAB=OPEN”,
“Value”: “Login | Xero Accounting Software”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “2000”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “assertText”,
“Target”: “xpath=//[@id="ext-gen25"]/div[2]/div[5]/div[3]/div[4]/label",
“Value”: “Total Credit”,
“Description”: “”
},
{
“Command”: “if_v2”,
“Target”: “${!LastCommandOk} == true”,
“Value”: “if total credit”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “id=ext-gen32”,
“Value”: “”,
“Targets”: [
“id=ext-gen32”,
"xpath=//
[@id="ext-gen32"]”,
“xpath=//div[@id=‘ext-gen32’]”,
“xpath=//dt/div”,
“css=#ext-gen32”
],
“Description”: “”
},
{
“Command”: “assertText”,
“Target”: “/html/body/div[2]/form/div/div[1]/div[2]/div[4]/div[3]/dl/dd/ul/li[1]/a”,
“Value”: “Allocate Credit”,
“Description”: “”
},
{
“Command”: “if_v2”,
“Target”: “${!LastCommandOk} == true”,
“Value”: “if apply is present”,
“Description”: “”
},
{
“Command”: “clickAndWait”,
“Target”: “//[@id="ext-gen28"]/ul/li[1]/a",
“Value”: “”,
“Description”: “”
},
{
“Command”: “times”,
“Target”: “20”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “verifyElementPresent”,
“Target”: “/html/body/div[2]/form/div/div[1]/div[2]/table/tbody/tr[${!times}]/td[5]”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “if_v2”,
“Target”: “${!LastCommandOk} == true”,
“Value”: “if present”,
“Description”: “”
},
{
“Command”: “storeText”,
“Target”: “id=AmountDue”,
“Value”: “remaining_credit”,
“Description”: “”
},
{
“Command”: “storeText”,
“Target”: “/html/body/div[2]/form/div/div[1]/div[2]/table/tbody/tr[${!times}]/td[5]”,
“Value”: “amount_due”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “var a = ${remaining_credit}; return a.replace(‘,’, ‘’);”,
“Value”: “remaining_credit”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “var a = ${amount_due}; return a.replace(‘,’, ‘’);”,
“Value”: “amount_due”,
“Description”: “”
},
{
“Command”: “if_v2”,
“Target”: “parseFloat (${remaining_credit}) - parseFloat (${amount_due}) >= 0”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “type”,
“Target”: “/html/body/div[2]/form/div/div[1]/div[2]/table/tbody/tr[${!times}]/td[6]/div/span/input”,
“Value”: “${amount_due}”,
“Description”: “”
},
{
“Command”: “sendKeys”,
“Target”: “/html/body/div[2]/form/div/div[1]/div[2]/table/tbody/tr[${!times}]/td[5]”,
“Value”: “${amount_due}”,
“Description”: “”
},
{
“Command”: “else”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “if_v2”,
“Target”: “parseFloat (${amount_due}) - parseFloat (${remaining_credit}) >= 0”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “type”,
“Target”: “/html/body/div[2]/form/div/div[1]/div[2]/table/tbody/tr[${!times}]/td[6]/div/span/input”,
“Value”: “${remaining_credit}”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “/html/body/div[2]/form/div/div[1]/div[2]/table/tbody/tr[${!times}]/td[5]”,
“Value”: “${amount_due}”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “else”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “gotoLabel”,
“Target”: “complete”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “label”,
“Target”: “complete”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: "//
[@id="ext-gen14"]”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “else”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “1000”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “selectWindow”,
“Target”: “TAB=CLOSE”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “clickAndWait”,
“Target”: “/html/body/div[2]/form/div/div[1]/div[2]/div[6]/ul/li[6]/a”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “gotoLabel”,
“Target”: " invoices",
“Value”: “”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
}
]
}

specifically the part from the while to select window, if i put the store as 1, the store attribute links to the column headers and returns that value, if I put the store as 2, it then pulls the 2nd credit note on the list. is there a reason why it would skip the first credit note?

Hi All

i take it there is no reason for this to occur?