![selenium处理div生成弹框 selenium处理div生成弹框](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
目前遇到的弹框有两种,一种是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定位弹框