Overview
This guide explains how to handle permission pop-ups for Android and iOS apps during Appium test execution. You can automatically allow or deny all permissions or selectively handle individual permission pop-ups.
Prerequisites
Before handling permission pop-ups, ensure the following:
Appium is configured for test execution.
DesiredCapabilities are configured in the test script.
Appium version 1.9.1 or above is being used for Android autoGrantPermissions capability.
Steps
Step 1: Grant All Permissions for Android Apps
Use Appium’s autoGrantPermissions capability to automatically determine and grant all required app permissions during installation.
Add the following capability in your test script:
DesiredCapabilities capabilities = new DesiredCapabilities();capabilities.setCapability("autoGrantPermissions", true);
Note - If the noReset capability is set to true, the autoGrantPermissions capability does not work.
Step 2: Allow or Deny All Permissions for iOS Apps
Use Appium’s autoAcceptAlerts capability to automatically allow all permission pop-ups.
Add the following capability in your test script:
DesiredCapabilities capabilities = new DesiredCapabilities();capabilities.setCapability("autoAcceptAlerts", true);
Use Appium’s autoDismissAlerts capability to automatically deny all permission pop-ups.
Add the following capability in your test script:
DesiredCapabilities capabilities = new DesiredCapabilities();capabilities.setCapability("autoDismissAlerts", true);
Note - These capabilities handle privacy access permission pop-ups such as:
Location access
Contacts access
Photos access
Step 3: Allow or Deny Specific Permission Pop-Ups
For selective test scenarios, individual permission pop-ups can be accepted or denied using element locators.
Android Example
driver.findElement(By.xpath(".//android.widget.Button[@text='Allow']")).click()iOS Example
driver.findElement(By.id("Allow")).click();
Outcome
After completing these steps:
Android app permissions can be granted automatically.
iOS permission pop-ups can be automatically accepted or dismissed.
Individual permission pop-ups can be handled selectively during test execution.
Still have a question?
Support Contact:
support@testgrid.io
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article