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
Internet explorer 如何在selenium中处理IE弹出窗口_Internet Explorer_Selenium - Fatal编程技术网

Internet explorer 如何在selenium中处理IE弹出窗口

Internet explorer 如何在selenium中处理IE弹出窗口,internet-explorer,selenium,Internet Explorer,Selenium,我正在使用selenium WebDriver为一个web应用程序编写测试,遇到了一个场景,当我尝试关闭浏览器时,会弹出一个弹出窗口,上面写着“确定吗?页面要求您确认是否要离开-输入的数据将丢失”。有两个按钮:离开页面和停留在页面上 我如何点击这些按钮?我试过这个 但它最后说没有警报处于活动状态。但实际上我可以看到弹出窗口 Utils.pressEnterKey(driver,driver.findElement(By.xpath(testSystem.getXPath("SearchBox")

我正在使用selenium WebDriver为一个web应用程序编写测试,遇到了一个场景,当我尝试关闭浏览器时,会弹出一个弹出窗口,上面写着“确定吗?页面要求您确认是否要离开-输入的数据将丢失”。有两个按钮:离开页面和停留在页面上

我如何点击这些按钮?我试过这个 但它最后说没有警报处于活动状态。但实际上我可以看到弹出窗口

Utils.pressEnterKey(driver,driver.findElement(By.xpath(testSystem.getXPath("SearchBox")))); 
Utils.waitForPageToLoad(driver);
String browser=TestSystem.getInstance().getBrowser();
if (browser.equalsIgnoreCase("IE"))
{System.out.println("IE handling");
driver.switchTo().alert().accept();
}

仅适用于IE此弹出问题。因此提供了一个检查。

您可以分享您的selenium代码吗?我认为您是在警报出现之前调用了警报函数。Utils.pressEnterKey(driver,driver.findElement(By.xpath(testSystem.getXPath(“SearchBox”)));Utils.waitForPageToLoad(驱动程序);字符串浏览器=TestSystem.getInstance().getBrowser();如果(browser.equalsIgnoreCase(“IE”){Utils.waitForPageToLoad(驱动程序);System.out.println(“IE处理”);driver.switchTo().alert().accept();}请与问题共享代码。在评论中很难阅读。