Using Appium 1.6, is it possible now to handle system based pop ups for IOS ?
If yes, can anyone help me with sample code.
Thanks in advance
created
Dec '16last reply
Jan '19- 15
replies
- 3.7k
views
- 6
users
Using Appium 1.6, is it possible now to handle system based pop ups for IOS ?
If yes, can anyone help me with sample code.
Thanks in advance
Maybe you are searching for
caps.setCapability(IOSMobileCapabilityType.AUTO_ACCEPT_ALERTS, Boolean.TRUE);
or
wait.until(ExpectedConditions.alertIsPresent());
driver.findElementByAccessibilityId("Ignore").click();
not the best solution, but it is also a solution:
wait.until(ExpectedConditions.visibilityOfElementLocated(MobileBy.xpath("//UIAApplication[1]/UIAWindow[7]/UIAAlert[1]")));I am running my tests with Appium 1.6.1 beta, Xcode 7.3.1 on iOS 9.3 simulator. and each of the snippets is working. Of course you have to adapt the xpath to your app structure if you want to use this option.
In my project I first used the ExpectedConditions.alertIsPresent() method, and changed it a couple of days ago to set the capabilities for automatic accepting all alerts. Till now everything works fine.
accepting alert within given time. useful when alert can appear or not by providing MAX time to wait in each case/step of test.
public boolean acceptAlert(int waitTimeInSec) { System.out.println(" wait to dismiss dialog"); WebDriverWait wait = new WebDriverWait(driver, waitTimeInSec); try { wait.until(ExpectedConditions.alertIsPresent()); driver.switchTo().alert().accept(); return true; } catch (Exception e) { System.err.println(" no alert visible after "+waitTimeInSec+" sec."); return false; } }