简体   繁体   中英

How to handle native iOS Alerts in Appium using Java

I try to write tests for an app, which shows iOS native alert for Location (This app would like to use your current location). I tried this code

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

This actually works for other alerts, but not for native ones.

Also I noticed, that since 2nd time I run a test(even there is nothing but an sysout), it fails because of SessionNotCreatedException, but if I remove that alert from app, everything is ok.

I use Appium 1.3.4. Thanks in advance.

Try adding to your Desired Capabilities ("autoAcceptAlerts",true) . It doesn't work perfectly but you should try it.

You can also try doing:

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

Hope this helps.

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