简体   繁体   中英

How can I allow system popup for location permission in Appium?

UI Automator查看器 I have tried few things to click on "OK" button for location permission Popup on Android:

  1. With MobileBy.
  2. With By locator.
  3. By adding capabilities mentioned on other solutions.

But nothing is working.

driver.findElement(By.xpath("//*[@id='button1']")).click();

As you have shared the screenshot thank you for that can you please try the xpath

Xpath:

driver.findElement(By.xpath("//android.widget.Button[@text='OK']")).click();

and let us know...^.^

For your app you can click ok using:

driver.findElementById("android:id/button1").click();

using xpath is not recommended in appium.

For android System permission pop up you can allow/deny permission by:

//to allow permission
driver.findElementById("com.android.packageinstaller:id/permission_allow_button").click();

//to deny permission
driver.findElementById("com.android.packageinstaller:id/permission_deny_button").click();

For ios system permission popup you can allow/deny permission by:

//to allow permission
driver.findElementByAccessibilityId("OK").click();

//to deny permission
driver.findElementByAccessibilityId("Don’t Allow").click();

You can also use add autoGrantPermissions=true (for android) and autoAcceptAlerts=true (for ios) capability in your DesiredCapabities .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM