Page 1 of 1

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

Posted: Thu Sep 26, 2019 10:56 am
by quynhnt
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

Regard,
quynhnt

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

Posted: Thu Sep 26, 2019 11:13 am
by odklizec
Hi,

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
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
Hope this helps?

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

Posted: Fri Sep 27, 2019 3:48 am
by quynhnt
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

Regard,
quynhnt