Java 输入区文本警报不存在';不要在SeleniumPlus Internet Explorer测试中拒绝
所以我有一个自动测试的方法,VerifyAndDismissAlert() 当在Chrome中运行时,当尝试在输入框中输入时,警报会弹出并解除 然而,在Internet Explorer中,警报会弹出并且不会消失。似乎警报甚至无法识别,因为当我被迫单击OK继续测试时,它会抛出Java 输入区文本警报不存在';不要在SeleniumPlus Internet Explorer测试中拒绝,java,selenium,selenium-webdriver,webdriver,automated-tests,Java,Selenium,Selenium Webdriver,Webdriver,Automated Tests,所以我有一个自动测试的方法,VerifyAndDismissAlert() 当在Chrome中运行时,当尝试在输入框中输入时,警报会弹出并解除 然而,在Internet Explorer中,警报会弹出并且不会消失。似乎警报甚至无法识别,因为当我被迫单击OK继续测试时,它会抛出 org.openqa.selenium.NoAlertPresentException: No alert is active 该测试与Chrome驱动程序完美配合,因此它必须与IE驱动程序配合使用。任何帮助都将不胜感激
org.openqa.selenium.NoAlertPresentException: No alert is active
该测试与Chrome驱动程序完美配合,因此它必须与IE驱动程序配合使用。任何帮助都将不胜感激 用于等待警报出现,在通过alert.accept()接受警报后,您将获得alert.getText()
肯定会抛出NoAlertPresentException。因为接受后警报不会出现。在接受或解除警报之前,必须使用类似alert.getText()的警报操作
WebDriverWait wait = new WebDriverWait(WD, 30);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = WD.switchTo().alert();
String alertText = alert.getText();
System.out.println(alertText);
alert.accept();
尝试设置等待时间?我尝试了这行代码“WebDriverWait wait=new WebDriverWait(WD,2)”,当弹出窗口出现时,您的测试是否挂起,您必须手动单击“确定”才能继续?我正在尝试找出代码的正确格式<代码>WebDriverWait wait=新的WebDriverWait(WD,2)代码>是我使用的try Thread.sleep(3000)问题是警报甚至没有被接受。测试将一直挂起,直到我手动单击“确定”
WebDriverWait wait = new WebDriverWait(WD, 30);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = WD.switchTo().alert();
String alertText = alert.getText();
System.out.println(alertText);
alert.accept();