在進行元素定位時常常遇到這樣的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
?