selenium远程驱动程序:无法接受窗口关闭时的警报-未找到窗口异常
我有一个弹出窗口,只要我点击submit按钮,弹出窗口就会关闭,并出现javascript警报 我在日志中得到:windownotfoundexception。 如果窗口未关闭,selenium能够识别警报,但由于弹出窗口已关闭,我得到上述异常 我曾尝试在单击提交按钮后使用$driver->switch\u to\u窗口,但这无法处理警报selenium远程驱动程序:无法接受窗口关闭时的警报-未找到窗口异常,selenium,Selenium,我有一个弹出窗口,只要我点击submit按钮,弹出窗口就会关闭,并出现javascript警报 我在日志中得到:windownotfoundexception。 如果窗口未关闭,selenium能够识别警报,但由于弹出窗口已关闭,我得到上述异常 我曾尝试在单击提交按钮后使用$driver->switch\u to\u窗口,但这无法处理警报 非常感谢您的任何想法。您是否正在使用Selenium的警报功能 public void checkAlert() { try { We
非常感谢您的任何想法。您是否正在使用Selenium的警报功能
public void checkAlert() {
try {
WebDriverWait wait = new WebDriverWait(driver, 2);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
alert.accept();
} catch (Exception e) {
//exception handling
}
}