How to automatically accept Alerts with Appium -- permissions Android 6.0

Andrey picture Andrey · Jun 7, 2017 · Viewed 12.3k times · Source

Environment:

  • OS Windows 7
  • Appium 1.4.16.1
  • Android emulator 6.0

I need to accept any permission alerts(Android 6.0 -- sms,location and etc) automatically.

What I tried:

  1. Use driver.switchTo().alert().accept();

    Result:

    org.openqa.selenium.WebDriverException: Not yet implemented. Please help us: http://appium.io/get-involved.html

  2. Set capabilities:

    capabilities.setCapability("autoGrantPermissions", "true"); capabilities.setCapability("autoAcceptAlerts", "true");

    Result: it doesn't work

Answer

SaiPawan picture SaiPawan · Jun 7, 2017

It wont work in appium.If your alert contains 'ALLOW' button.Try to use below code:

driver.findElementByAccessibilityId("ALLOW").click();

This will click on "ALLOW" button which means accepting the alert.