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

利用selenium webdriver点击alert提示框

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

 

利用selenium webdriver点击alert提示框

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();

 

利用selenium webdriver点击alert提示框

附几个相关链接:

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

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

 

相关文章:

  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2022-12-23
  • 2021-12-02
  • 2022-01-05
  • 2022-03-06
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案