-1

我在 Selenium Androiddriver 中使用了这段代码

WebDriverWait waiter = new WebDriverWait(driver, 30); 
Alert alert = waiter.until(ExpectedConditions.alertIsPresent());

但我收到下面的错误消息。

org.openqa.selenium.WebDriverException: Method has not yet been implemented

有什么方法可以做到这一点?

4

1 回答 1

1

此错误消息...

org.openqa.selenium.WebDriverException: Method has not yet been implemented

...暗示当您尝试将返回类型从ExpectedConditions方法分配给Alert的实例时引发了WebDriverExceptionalertIsPresent()

WebDriverWait结合使用时,ExpectedConditions方法等待警报出现,并在出现警报后切换到警报,您可以直接调用以下任一方法或如下所示:alertIsPresent()accept()dismiss()

  • accept()

    new WebDriverWait(driver, 10).until(ExpectedConditions.alertIsPresent()).accept();
    
  • dismiss()

    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;
于 2018-05-21T19:53:15.180 回答