new WebDriverWait(driver, 6).until(ExpectedConditions.alertIsPresent());
driver.switchTo().alert().accept();
在进行alert操作前,先等待警报显示,即等弹框出来。
参考:
https://stackoverflow.com/questions/17749064/selenium-noalertpresentexception
本文探讨了在使用Java和Selenium自动化测试时遇到`NoAlertPresentException`异常的问题。解决方法是在尝试操作alert之前,确保通过等待机制等待警报框出现。
new WebDriverWait(driver, 6).until(ExpectedConditions.alertIsPresent());
driver.switchTo().alert().accept();
在进行alert操作前,先等待警报显示,即等弹框出来。
参考:
https://stackoverflow.com/questions/17749064/selenium-noalertpresentexception
461
4471

被折叠的 条评论
为什么被折叠?