在测试过程中发现页面上有两个保存按钮的元素的xpath一模一样,如下图:

selenium 定位 页面上两个完全一样的元素

google了好久才找到解决办法,发现自己还是比较弱!!!解决方法如下:

 

 

selenium.click("xpath=(//button[.='保存'])[last()]");
 

使用 last() 这个函数(我去,xpath还支持函数!!!)

 

 

其它函数请查看下面的网页:http://automationtricks.blogspot.com/2010/09/how-to-locate-element-which-have-same.html

--------------------- 本文来自 su1322339466 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/su1322339466/article/details/51770326?utm_source=copy 

相关文章:

  • 2022-03-05
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2021-12-05
  • 2022-12-23
  • 2021-05-27
  • 2021-11-09
猜你喜欢
  • 2021-04-17
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-02
  • 2021-11-15
相关资源
相似解决方案