3

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

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。有什么解决方法吗?

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

提前致谢。

4

3 回答 3

4

Please use the below code for your need:

To wait for the alert to appear:

wait.until(ExpectedConditions.alertIsPresent());

To wait for the alert to disappear:

wait.until(!ExpectedConditions.alertIsPresent());
于 2014-07-09T09:29:56.670 回答
0

对我来说,当我这样做以接受带有 OK 按钮的警报对话框时,它可以工作

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

但是点击动作完成后,我的程序停止检测元素

于 2014-09-23T12:32:31.843 回答
0

等待警报消失:

wait.until(ExpectedConditions.not(ExpectedConditions.alertIsPresent()));
于 2015-10-05T00:32:11.017 回答