如何处理在使用Android的警报appium [英] how to handle alerts in android using appium

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

问题描述

我如何处理使用Appium服务器(1.0.1)和Android SDK在Android Web应用程序警报?

下面code不工作在Android:

  driver.switchTo()接受()警报()。

错误消息:

 > -modal窗口不关闭后得到


解决方案

您需要在尝试之前得到警报和接受

这是从一些<一code href=\"https://github.com/appium/java-client/blob/7772a4c4b8760982b0f9ded4585b4a4c1fa87cba/src/test/java/io/appium/java_client/iOSGestureTest.java#L74\"相对=nofollow> Appium Java客户端测试的:

  wait.until(ExpectedConditions.alertIs present());
。警报警报= driver.switchTo()报警();
alert.accept();

这应该工作的大部分时间。

如果接受()不工作,则更换 driver.switchTo()警报(); alert.accept(); 与code查找按钮,然后点击

如果它没有找到该按钮包装 findElementBy(方法) code在try /重试块,而然后的一下就可以了

How do I handle alerts in an Android web application using Appium server (1.0.1) and the Android SDK?

The below code is not working on android:

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

Error message:

> -modal window does not get closed

解决方案

You need to get the Alert before you try and accept it

This is code from some of the Appium Java Client Tests:

wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
alert.accept();

This should work most of the time.

If accept() isn't working, replace the driver.switchTo().alert(); and alert.accept(); with code to find the button and then click it.

If it's not finding the button wrap findElementBy(Method) code in a try/retry block, and then click on it.

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

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