[英]How to get xpath for this element
I have lot of tr tag with same structure in my page . 我的页面中有很多具有相同结构的tr标签。 The only way to select "Google" is by starting the XPATH from "ImgTrash.png" .
选择“ Google”的唯一方法是从“ ImgTrash.png”启动XPATH。 Please let me know if you have idea .
如果您有想法请告诉我。
<tr> <td width="1%"/> <td class="Fol" nowrap="" style="padding-left: 0px"> <a id="A57" href="3745474"> <img src="ImgTrash.png"/> <span style="vertical-align:middle">Trash </span> </a> </td> </tr> <tr class="Row"> <td width="1%"/> <td class="Fol" nowrap="" style="padding-left: 8px"> <a id="A56" href="507023"> <img src="ImgFolder.png"/> <span style="vertical-align:middle">Google </span> </a> </td> </tr>
You will need an XPath like this: 您将需要这样的XPath:
//a[img/@src = 'ImgFolder.png']/span
Breakdown: 分解:
//a
searches for all <a>
elements //a
搜索所有<a>
元素 [img/@src = 'ImgFolder.png']
only selects the <a>
elements that have a child <img>
with the attribute src
. [img/@src = 'ImgFolder.png']
仅选择具有子元素<img>
且属性为src
的<a>
元素。 This attribute src
should exactly match (case-sensitive) ImgFolder.png
src
应该完全匹配(区分大小写) ImgFolder.png
/span
at the end will get the child <span>
from the previous selected <a>
/span
末尾将从先前选择的<a>
获得子<span>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.