Open link in new tab

Hi All

got a scenario going and come to a point where I have to open a link in a new tab, due to if I open it in the current tab with click, when going back to the original page, it goes to the first page of items where I could have been on page 3.

tried using the xclick #right, but it doesn’t seem to click exactly where required and a little to the side, meaning the popup isnt the right one, and doesnt show the open in new tab for me to use xtype function.

is there another way to get the tab to open in a new window

and #ctrlclick doesnt appear to open in a new tab either.

Try to test this if you are using browser automation and replace the link by yours
selectWindow | TAB=OPEN | https://newwebsiteURL.com this opens a new tab and loads the website with the given URL.

The problem with this is that it’s a website with a given URL. what if the URL is unique to the link on the website, as this is, its individual invoices, can you specify an element instead?

You can get your URL using click by recording the action or extracting your link path from your web page source code

click wont work as the name changes continously for each invoice. unless i store that name and reference it over and over as well, but the below might be easier?

I did see there is a store attribute function in uivision, which could solve the problem, but could I get an example of how to use this to extract the href data from the element?

Jacobs Bernadine (31813350(C))

actual code a class=“nav” href=“ViewCreditNote.aspx?creditNoteID=ef3e666a-85ed-4346-9eff-2ad031bdb068” id=“ext-gen43”>Jacobs Bernadine (31813350(C))</a

thanks for the help

Try this command
Click | xpath=//a[contains(@href,“type here the repetitive part from you href”)]
E.g. xpath=//a[contains(@href,“svenarndt”)]

Morning (if its your morning)

i appear to be doing something wrong somewhere

to make it a dynamic field, I told it to first storetext of the relevant invoice I want, eg Jacobs Bernadine (31813350(C))

i then did the click like this

{
“Command”: “click”,
“Target”: “//a[contains(@id,“${name}”)]”,
“Value”: “LINK”,
“Description”: “”
},

I did ID instead of Href as it appears to be a part of the id section above, the value is being transferred across the click function and comes out as

Line 9: timeout reached when looking for element ‘//a[contains(@id,“Jacobs Bernadine (31813350(C))”)]’

I tried the same concept looking through the href instead of ID, same result. when using the View term from the href code above, same result.

seems I am not understanding a concept here.

Good morning,

Looks like there is something wrong in your command, have you tried the @href instead of @id ?
you can run this test to understand more how it works, it’s very simple :

{
  "Name": "Go to wikipedia and click english",
  "CreationDate": "2021-9-29",
  "Commands": [
    {
      "Command": "store",
      "Target": "true",
      "Value": "!errorignore",
      "Description": ""
    },
    {
      "Command": "open",
      "Target": "https://www.wikipedia.org/",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "waitForPageToLoad",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//a[contains(@title,\"English\")]",
      "Value": "",
      "Description": ""
    }
  ]
}

concept seems simple enough, and yet it doesnt work on my side.

I copied your code and pasted and adjusted as required, tried the id and href, and both times it could not find it. what I essentially need is the href link in the image below extracted, and then opened in a new window, while dynamically changing what link to extract, and the only thing that changes i can search for is the persons name after the id ext-genXXX

Can you share your web page or any web page with similar problem?

this is accounting software that requires login etc, an account could be made and the demo company used, but I can’t share anything with you specifically.

I tested it on not alwaysright.com and it worked fine

the only difference i can spot is

notalwaysright

a id=“inactivetab” href=“/working/”>Working</a

xero

a class=“nav” href=“View.aspx?InvoiceID=88617351-56ed-4c14-a30d-34a006d0a75a” id=“ext-gen43”>Bayside Club</a

when i used the formula

“xpath=//a[contains(@href,"working”)]",

it navigated as it should

use xpath=//a[contains(@href,“bayside”)]

and it times out. if i use ID instead of @href, times out as well. this would suggest the bayside does not form part of the ID or href?

This should work fine. Note that XClick | ... | #ctrlclick on the link opens the page in new tab, but does not switch to the new tab! => For this, you need to use selectWindow | tab=1 afterwards. This command switches to the tab on the right of the currently active tab.

Test:

{
  "Name": "control click",
  "CreationDate": "2021-9-30",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://forum.ui.vision/",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "comment",
      "Target": "click // linkText=Categories",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "XClick",
      "Target": "linkText=Categories",
      "Value": "#ctrlclick",
      "Targets": [
        "linkText=Categories",
        "xpath=//*[@id=\"ember36\"]/a",
        "xpath=//li[3]/a",
        "css=#ember36 > a"
      ],
      "Description": ""
    },
    {
      "Command": "selectWindow",
      "Target": "TAB=1",
      "Value": "",
      "Description": "tab=1 is the first tab to the right, COUNTED FROM the currently active tab"
    },
    {
      "Command": "click",
      "Target": "linkText=Selenium IDE",
      "Value": "",
      "Description": ""
    }
  ]
}

the functions works and clicks, but it opens it in the current tab instead of a new tab, tested it manually and it worked as expected, so the command is not registering the ctrl click, just the click

{
“Command”: “XClick”,
“Target”: “/html/body/div[2]/form/div/div[1]/div[2]/table/tbody/tr[1]/td[4]/a”,
“Value”: “#ctrlclick”,
“Description”: “”
},

Interesting. As a test:

What if you use an image instead of an Xpath locator, does it work then?

its a dynamic field, the name on the link changes per invoice.

Then you can try with XClickRelative :wink: => The anchor image (green box) in this case would be something next to the link that does not change. And the pink box for the click is at the link.

would not work, due to this being the list. and this is just a example, the name in blue is the link, and could change to whatever customer that invoice is for.

so using an image/relative location, would require replicating it 100 times

Ok, I see. But as a test (with one fixed link): Does XClick | image | #ctrlclick work?

Once we know if that works or not, we can take it from there :wink:

same result as before, it navigated to the right spot, but then opened in the current tab. FYI, The demo account in Xero it exactly the same across all users, so if you used that one as a test ground, it would be exactly the same as the one I see.