利用selenium webdriver点击alert提示框
生活随笔
收集整理的這篇文章主要介紹了
利用selenium webdriver点击alert提示框
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
在進(jìn)行元素定位時(shí)常常遇到這樣的alert框:
那么該如何定位并點(diǎn)擊確定或取消按鈕呢?stackoverflow上找到了這個(gè)問題的答案。
?
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();如果是點(diǎn)取消,則:
alert.dismiss();
?
附幾個(gè)相關(guān)鏈接:
http://www.cnblogs.com/qiaoyeye/p/5593428.html
http://sanwen8.cn/p/w3dEEE.html
?
轉(zhuǎn)載于:https://www.cnblogs.com/songshu120/p/6163504.html
總結(jié)
以上是生活随笔為你收集整理的利用selenium webdriver点击alert提示框的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python爬虫入门之Urllib库的基
- 下一篇: wampserver 虚拟主机