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

查看:150
本文介绍了如何使用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.

另外我注意到,自从我第二次运行测试(即使只有一个sysout),它因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天全站免登陆