标签:
public static boolean isAlertPresent(WebDriver driver) {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException ex) {
return false;
}
}
/**
* Sometimes will pop up an alert window, you can use this method to close
* it.
*/
public static void closeAlert(WebDriver driver, boolean acceptAlert) {
Alert alert = driver.switchTo().alert();
if (acceptAlert) {
alert.accept();
} else {
alert.dismiss();
}
}
标签:
原文地址:http://www.cnblogs.com/feifeidxl/p/4551028.html