I am trying to run my Appium tests on real iOS device. However, I cannot figure how to switch between tabs on Safari. I open a page on Safari using Appium IOSDriver instance. I then click a link on the page that opens a new tab. Now I wish to close this tab or at least switch back to the original window.
I have tried the following solutions but none of them seem to help:
Perform touch action to open the tabs interface, did not manage to click the tabs option.
TouchAction ta = new TouchAction(driver); int h=driver.manage().window().getSize().getHeight(); int w=driver.manage().window().getSize().getWidth(); ta.tap(h-50,w-50).perform();Tried switch back to original context, did not help
for (String contextName : contextNames) { if(!contextName.equals(original)) { WebViewContext = contextName; ((AppiumDriver) driver).context(WebViewContext); Thread.sleep(4000); driver.close(); } }Tried Javascript, no success
Set<String> windows = driver.getWindowHandles(); String currentHandle = driver.getWindowHandle(); ((JavascriptExecutor)driver).executeScript("window.open();"); Set<String> newWindow = driver.getWindowHandles(); newWindow.removeAll(windows); driver.switchTo().window(original);