Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
selenium远程驱动程序:无法接受窗口关闭时的警报-未找到窗口异常_Selenium - Fatal编程技术网

selenium远程驱动程序:无法接受窗口关闭时的警报-未找到窗口异常

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

我有一个弹出窗口,只要我点击submit按钮,弹出窗口就会关闭,并出现javascript警报

我在日志中得到:windownotfoundexception。 如果窗口未关闭,selenium能够识别警报,但由于弹出窗口已关闭,我得到上述异常

我曾尝试在单击提交按钮后使用$driver->switch\u to\u窗口,但这无法处理警报


非常感谢您的任何想法。

您是否正在使用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
    }
}