---
title: Handling Permission Popups with Appium | TestingBot
description: How to deal with user-permission dialogs during Appium testing on iOS
  and Android.
source_url:
  html: https://testingbot.com/support/app-automate/appium/permission-popups
  md: https://testingbot.com/support/app-automate/appium/permission-popups/index.md
---
# Handling permission pop-ups

While testing your mobile app, it may ask for specific permissions during the test. Various system dialogs or popups may appear, asking the user to grant access.   
 The mobile app might ask the user permission to access the contacts, notifications, media, ... on the device.

Below we'll go over the various techniques to handle these events during your mobile testing:

- [Allow or Deny all permissions](https://testingbot.com#allPermissions)
- [Allow or Deny specific permissions](https://testingbot.com#specificPermissions)

## Allow or Deny all permissions

Appium allows you to automatically accept all permission and alert requests.

### Allow or Deny all permissions on Android

You can use the `autoGrantPermissions` capability.

Appium will inspect the [Android Manifest](https://developer.android.com/guide/topics/manifest/manifest-intro) of the app, extract the required permissions and grant these.

[Ruby](https://testingbot.com#)[Python](https://testingbot.com#)[Java](https://testingbot.com#)[NodeJS](https://testingbot.com#)[C#](https://testingbot.com#)

    caps["appium:autoGrantPermissions"] = true

    options.setCapability("appium:autoGrantPermissions", true);

    capabilities = {
      "appium:autoGrantPermissions": True
    }

    const capabilities = {
        "appium:autoGrantPermissions": true
    }

    options.AddAdditionalAppiumOption("appium:autoGrantPermissions", true);

  

### Allow or Deny all permissions on iOS

On iOS, Appium offers two capabilities which you can use: `autoAcceptAlerts` and `autoDismissAlerts`.

`autoAcceptAlerts` will automatically accept (grant) any alerts (including permission popups) that might appear during your test.   
`autoDismissAlerts` will automatically dismiss (deny) any alerts (including permission popups) that might appear during your test.

[Ruby](https://testingbot.com#)[Python](https://testingbot.com#)[Java](https://testingbot.com#)[NodeJS](https://testingbot.com#)[C#](https://testingbot.com#)

    caps["appium:autoAcceptAlerts"] = true # to accept all alerts
    caps["appium:autoDismissAlerts"] = true # to dismiss all alerts

    options.setCapability("appium:autoAcceptAlerts", true); // to accept all alerts
    options.setCapability("appium:autoDismissAlerts", true); // to dismiss all alerts

    # Set one of the following capabilities:
    capabilities["appium:autoAcceptAlerts"] = True # to accept all alerts
    capabilities["appium:autoDismissAlerts"] = True # to dismiss all alerts

    // Set one of the following capabilities:
    capabilities["appium:autoAcceptAlerts"] = true; // to accept all alerts
    capabilities["appium:autoDismissAlerts"] = true; // to dismiss all alerts

    options.AddAdditionalAppiumOption("appium:autoAcceptAlerts", true); // to accept all alerts
    options.AddAdditionalAppiumOption("appium:autoDismissAlerts", true); // to dismiss all alerts

### Customizing the alert button selector

There may be dialogs that appear during your automated tests which have 3 buttons instead of 2, or there's a specific button you want to press instead of the default (allow) button.

In this case, you might want to consider using the `acceptAlertButtonSelector` Appium setting, which allows you to pass a selector (a [class-chain expression](https://github.com/facebookarchive/WebDriverAgent/wiki/Class-Chain-Queries-Construction-Rules)) to tell Appium which button to click.

For example, you might want to click the 'Allow Once' button in a location permission dialog. To instruct Appium to do this, you can change the `acceptAlertButtonSelector` setting during your test:

    driver.updateSettings({
        acceptAlertButtonSelector: "**/XCUIElementTypeButton[`label CONTAINS[c] 'Allow Once'`]"
    });

Alternatively, you can set this setting at the beginning of your test with a capability:

    const capabilities = {
      "appium:settings": {
        "acceptAlertButtonSelector": "**/XCUIElementTypeButton[`label CONTAINS[c] 'Allow Once'`]"
      }
    }

## Allow or Deny specific permissions

You can also choose to accept or deny alerts and popups during your test.   
 Your test will need to find the element of the alert or popup and perform a `click` action on that element.

[Ruby](https://testingbot.com#)[Python](https://testingbot.com#)[Java](https://testingbot.com#)[NodeJS](https://testingbot.com#)[C#](https://testingbot.com#)

    # For Android
    driver.find_element(:xpath, ".//android.widget.Button[@text='Allow']").click
    # For iOS
    driver.find_element(:id, "Allow").click

    // For Android
    driver.findElement(By.xpath(".//android.widget.Button[@text='Allow']")).click();
    // For iOS
    driver.findElement(By.id("Allow")).click();

    from selenium.webdriver.common.by import By
    
    # For Android
    driver.find_element(By.XPATH, ".//android.widget.Button[@text='Allow']").click()
    # For iOS
    driver.find_element(By.ID, "Allow").click()

    // For Android
    const element = await driver.$(".//android.widget.Button[@text='Allow']");
    await element.click();
    // For iOS
    const allowBtn = await driver.$("#Allow");
    await allowBtn.click();

    // For Android
    IWebElement ll = driver.FindElement(By.XPath(".//android.widget.Button[@text='Allow']"));
    ll.Click();
    // For iOS
    IWebElement ll = driver.FindElement(By.Id("Allow"));
    ll.Click();

Was this page helpful? Yes No 

## Looking for More Help?

Have questions or need more information?   
 You can reach us via the following channels:

- [Email us](https://testingbot.com/contact/new)
- [Join our Slack Channel](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
