利用selenium webdriver点击alert提示框


在进行元素定位时常常遇到这样的alert框:

那么该如何定位并点击确定或取消按钮呢?stackoverflow上找到了这个问题的答案。

 

OK, Show you the code:

1 driver.findElement(By.id("updateButton")).click();
2 //pop up with id "updateButton" opens
3 Alert alert = driver.switchTo().alert();
4 //update is executed
5 alert.accept();

如果是点取消,则:

alert.dismiss();

 

附几个相关链接:

http://www.cnblogs.com/qiaoyeye/p/5593428.html

http://sanwen8.cn/p/w3dEEE.html

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM