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

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

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 

原文地址:https://www.cnblogs.com/peachh/p/9739971.html