如何使用 Java 在 Appium 中处理本机 iOS 警报 [英] How to handle native iOS Alerts in Appium using Java

查看:19
本文介绍了如何使用 Java 在 Appium 中处理本机 iOS 警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试为一个应用编写测试,该应用显示 iOS 本机位置警报(此应用想使用您当前的位置).我试过这个代码

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.

我还注意到,自从我第二次运行测试(即使只有一个系统输出),它由于 SessionNotCreatedException 而失败,但如果我从应用程序中删除该警报,一切正常.

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.

我使用 Appium 1.3.4.提前致谢.

I use Appium 1.3.4. Thanks in advance.

推荐答案

尝试添加到您想要的功能 ("autoAcceptAlerts",true).它无法完美运行,但您应该尝试一下.

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

您也可以尝试这样做:

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

希望这会有所帮助.

这篇关于如何使用 Java 在 Appium 中处理本机 iOS 警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆