目前遇到的弹框有两种,一种是alert,一种是div,如果遇到div模拟的弹框,在用alert就不行了。
1.
public static Alert getAlert(WebDriver dr) {
try{
Alert alert = dr.switchTo().alert();
return alert;
}catch(NoAlertPresentException e) {
System.out.println("alert not Exist");
return null;
}
}
2.div
用findelement定位弹框