How to close tab on Browser native (Chrome/Safari)

Mobile Testing, Android App Testing.
Posts: 8
Joined: Fri Jul 26, 2019 8:37 am

How to close tab on Browser native (Chrome/Safari)

Post by quynhnt » Thu Sep 26, 2019 10:56 am

Hi All

I am testing chrome/safari on real device (Android/iOS).
I am using Ranorex Studio 8.3 and Appium Desktop 1.14.0
At the "1st tab", Click on an item -> Open "2nd tab"
after opening 2nd tab, I think appium is handling on 1st tab
Result: auto switch on "1st tab"
I cannot run the script for the "2nd tab"
How to close "1st tab" or be controllable "2nd tab"
Please help me! :D

Example.png (1.73 MiB) Viewed 778 times

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

Re: How to close tab on Browser native (Chrome/Safari)

Post by odklizec » Thu Sep 26, 2019 11:13 am


The problem is most probably caused by xpaths, which are not optimized for second tab? I guess the same issue will happen if you run your script on desktop? Could you please post an example of failing xpath, you are using in repo?

You see, if the xpath returns more than one element, Ranorex always uses the first element from the list of found elements. And because both tabs contains the same elements, your xpath most probably returns multiple elements from both tabs.
HiddenTab.png (54.45 KiB) Viewed 774 times
What you can try is to add @visible attribute to xpath of DOM element. With this, Ranorex should return only elements from visible tab...
VisibleTab.png (52.58 KiB) Viewed 774 times
Hope this helps?
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

Posts: 8
Joined: Fri Jul 26, 2019 8:37 am

Re: How to close tab on Browser native (Chrome/Safari)

Post by quynhnt » Fri Sep 27, 2019 3:48 am

Hi odklizec

Thank your information
The problem does not arise on the desktop

On mobile device.
Ranorex controls the mobile browser via appium web driver.
After opening a new tab, I think appium keeps the session with the old tab.
So automatically back to the old tab.

I did the following experiment

1. In the appium server running state.
I tried swicht to the new tab manually touch operation.
However, after switching to a new tab, it will automatically back to the old tab.

2. In the appium server off state.
It did not happen automatically switch back on the old tab.

After opening a new tab I want ranorex active on a new tab.
I want to close the old tab and keep the new tab.
I used the CloseWindow, however it closed all tabs.
Is there any way to close any tab in mobile device's browser?

Please help me