如何使用 appium 在 android 中处理警报 [英] how to handle alerts in android using appium
本文介绍了如何使用 appium 在 android 中处理警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在使用 Appium 服务器 (1.0.1) 和 Android SDK 的 Android Web 应用程序中处理警报?
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();
错误信息:
> -modal window does not get closed
推荐答案
最好的方法是使用 appium 检查器.单击该元素并从中复制 resource-id.在 findElement(By.id()) 方法中使用此资源 ID.
The best way is to use the appium inspector. Click on the element and copy the resource-id from it. Use this resource id in findElement(By.id()) method.
对我来说资源 ID:android:id/button1
For me resource-id: android:id/button1
((AndroidDriver) driver).findElement(By.id("android:id/button1")).click();
这是针对安卓的.对于经常使用,您可以使用
This is for Android. For regular use you can use
driver.findElement(By.id("android:id/button1")).click();
这篇关于如何使用 appium 在 android 中处理警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文