利用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