我在Selenium Androiddriver中使用了这段代码
WebDriverWait waiter = new WebDriverWait(driver, 30);
Alert alert = waiter.until(ExpectedConditions.alertIsPresent());
但我收到以下错误消息。
org.openqa.selenium.WebDriverException: Method has not yet been implemented
有什么方法可以实现这个目标?
答案 0 :(得分:1)
此错误消息......
org.openqa.selenium.WebDriverException: Method has not yet been implemented
...表示当您尝试将 ExpectedConditions 方法alertIsPresent()
的返回类型分配给警报的实例时,引发了 WebDriverException
ExpectedConditions 方法alertIsPresent()
与 WebDriverWait 一起使用时,等待警报出现并切换到<一旦警告存在,就会发出警告,您可以直接调用accept()
或dismiss()
,如下所示:
new WebDriverWait(driver, 10).until(ExpectedConditions.alertIsPresent()).accept();
new WebDriverWait(driver, 10).until(ExpectedConditions.alertIsPresent()).dismiss();
注意:您需要添加以下导入:
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.Alert;