Managing Browser Tabs

Ask general questions here.
Posts: 1
Joined: Tue Aug 11, 2020 9:51 pm

Managing Browser Tabs

Post by krish299 » Tue Aug 11, 2020 9:55 pm

Hello, I was just wondering how Ranorex manages browser tabs. For example, if I want to close a browser tab, how can I accomplish that? If I want a test to focus on a certain tab, how do I do that? I searched for this question in the forum, but the responses appear to be dated.

User avatar
Ranorex Guru
Ranorex Guru
Posts: 6553
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Managing Browser Tabs

Post by odklizec » Mon Aug 17, 2020 8:42 am


I'm afraid, there is no simple or automatic solution for handling browser tabs. Browser tabs are a part of browser form and each browser uses different structure of UI. So, in case you need to run the same test on multiple browsers, you will have to find an xpath, with common UI elements. For example, this xpath returns all browser tabs in IE, Chrome and FireFox:

Code: Select all

/form[@processname='firefox' or @processname='chrome' or @processname='iexplore']//tabpagelist[@accessiblerole='PageTabList'][@visible='true']//tabpage
To click specific browser tab, you must, of course specify tabname, so the xpath to find a specific tab, should look like this...

Code: Select all

/form[@processname='firefox' or @processname='chrome' or @processname='iexplore']//tabpagelist[@accessiblerole='PageTabList'][@visible='true']//tabpage[@accessiblename>'MacRumors: Apple Mac iPhone']
Of course, you can variabilize it and connect it to data connector of your choice...

Code: Select all

/form[@processname='firefox' or @processname='chrome' or @processname='iexplore']//tabpagelist[@accessiblerole='PageTabList'][@visible='true']//tabpage[@accessiblename>$varName]
And here is the result in spy, which displays the same tab in all three browser. You can see how different is the UI structure in each browser ;)
BrowserTabs.png (87.33 KiB) Viewed 216 times
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration