Page tree
Skip to end of metadata
Go to start of metadata

Last updated: Nov 26, 2019 10:04

With iOS 13, Apple has introduced further hardening of privacy and security settings. Part of this is the addition of new system popups that give users better control over their privacy. This includes popup notifications to verify that users approve app access to location, contacts, and photos while the app is open or working in the background. Because these popups may disrupt automation flows, your implementation should be aware of such popups and have an effective handling mechanism.   

These are examples of the most common prompts, followed by proposed solutions:

  • Prompts for permission to access location, contacts, or photos while using the apps:

  • Prompts for permission to access location, contacts, or photos when the app is running in the background:

  • Prompts that request use of known nearby Wi-Fi networks or Bluetooth devices:

To mitigate such behavior in your automated tests with Perfecto, you can:

  • Add the autoAcceptAlerts or autoDismissAlerts capability to the driver with a value of true that accepts (or rejects) all access requests during test execution.
    For example:

    capabilities.setCapability("autoAcceptAlerts", true);

    capabilities.setCapability("autoDismissAlerts", true);

    Note: The current behavior of autoDismissAlerts and autoAcceptAlerts is counter-intuitive when it comes to popups with more than two buttons. For such popups, if you want to automatically:

    • Dismiss alerts: Use autoAcceptAlerts.
    • Accept alerts: Use autoDismissAlerts.
  • Use a simple try-catch pattern to accept alerts when they are expected to pop up in your test by finding the Allow buttons with a generic locator.
    For example:

    try {
    getDriver().findElementByXPath("//*[contains(@label,'Allow While Using')]").click();
    } catch (Exception e) {
    e.printStackTrace();
    }
  • Use the Java class discussed in the Pop-up eliminator framework article as a model for a popup eliminator class in an application test script or as a framework for general popup elimination.