编程语言
首页 > 编程语言> > java-如何使用Appium通过硒找到警报对话框?

java-如何使用Appium通过硒找到警报对话框?

作者:互联网

在应用程序中以这种方式实现了一个对话框:

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Something");
builder.setTitle("Something");
dialog = builder.create();
dialog.show();

如何在Appium测试脚本中找到此元素?

driver.switchTo().alert();抛出NotImplementError

driver.findElement(By.tagName(“ AlertDialog”))无法正常工作

我在Github上发现了Alert methods NYI问题.有什么解决方法吗?

顺便说一句,我不会在该对话框上单击“确定”或“取消”,我将等到该对话框自动消失.

提前致谢.

解决方法:

请根据需要使用以下代码:

要等待警报出现:

wait.until(ExpectedConditions.alertIsPresent());

要等待警报消失:

wait.until(!ExpectedConditions.alertIsPresent());

标签:selenium,android-testing,java,appium
来源: https://codeday.me/bug/20191029/1963180.html