简体   繁体   中英

How to accept this alert in appium?

Appium v1.6.4-beta Xcode 8.2 macOs Sierra 10.12

I want to automate to save photo in my device. But in first time I have to give permission. I have used "accept alert", but cannot accept the alert for allow to access the photo library. It shows the test passed in green , when I execute the test, but this popup still appear in view and photo is not saved.

This is my script

//Check Save 
driver.findElement(By.id("Save")).click();
driver.switchTo().alert().accept();

Capabilities also used ,

 capabilities.setCapability("autoAcceptAlerts", true);

This is what I want to allow

在此处输入图片说明

How to accept this alert? I have tried with xpath sa well, but no luck

Below code will work.Give it a try with "OK" and "Ok". This is because if you want to try to identify the element with the text you can use accessibilityID or ID.

driver.findElement(By.id("OK")).click();

Below code won't work for alerts coming in mobile automation like web alerts.

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

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