![webdriver中处理alert webdriver中处理alert](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
1 定义isAlertPresent()供调用;
public boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException Ex) {
return false;
}
}
2 处理弹出的alert;
while (new Sgzzsjps_Action(driver).isAlertPresent()){
driver.switchTo().alert().accept();
Thread.sleep(3000);
}