IOS 10: Handle system pop ups


#1

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


#2

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]")));

#3

Will this work for any version of iOS or this is specific to ios 10 ?


#4

For each version, since these solutions are not using iosAutomation or predicates


#5

This has not helped me with ios versions < 10. Hence before making changes to my code in framework, I want to make sure that it helps with ios 10 so that I can select my test cases and do the remaining setup too. Can you please confirm if this will work for ios 10 or versions less than ios 10 ?


#6

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.


#7

I am not talking about application pop ups here. Those pop ups I can handle. I am talking about pop ups generated by system like software installation pop ups generated by iOS. Can you handle them ? (Not application pop ups)


#8

I’m able to handle pop ups asking for permissions like location or calendar, and also these for updating the app if its outdated


#9

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;
    }
}

#10

This works for handling system based pop ups ?
Any specific configuration or installation required ?


#11

nothing required. driver must be iOSDriver. accepting works for me with Simulator and alert like: “World you like to allow access to Contacts?”.


#12

Many access are required in my app and on real devices


#13

Would that also work fine on real ios 10 iPhone and iPad when an incoming call comes in or you need to change some system settings like WiFi etc.?


#14

Will this work for real ios device ?

It worked on real device.


#15

Hi , I was able to handle alerts on Xcode 8.3.3 and Appium 1.6.6 with

driver.findElementById(“OK”).click().

but does not works after I upgraded to Xcode 9.

I am using AppiumDriver


#16

It works correctly in OS: 10.3.1 and xcode 9.2, thanks