webdriver中处理alert

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);
           } 

原文地址:https://www.cnblogs.com/tiancy/p/5102806.html