如何定位网页中只有一个属性且与其他元素重复的元素?
How to locate the element which has only one attribute and is duplicate with other elements in the webpage?
<html>
<tr id="userman-orgchart-tree-node-9" class="fancytree-expanded fancytree-folder fancytree-has-children fancytree-exp-e fancytree-ico-ef">
<td>
<span class="fancytree-node" style="padding-left: 16px;">
<span class="fancytree-expander"></span>
<span class="fancytree-icon"></span>
<span class="fancytree-title">Legal</span>
</span>
</tr>
<tr id="userman-orgchart-tree-node-10" class="fancytree-active fancytree-folder fancytree-has-children fancytree-exp-c fancytree-ico-cf">
<td>
<span class="fancytree-node" style="padding-left: 16px;">
<span class="fancytree-expander"></span>
<span class="fancytree-icon"></span>
<span class="fancytree-title">Branch Performance Test</span>
</span>
</tr>
</html>
在这里,在上述情况下,我如何编写一个元素定位器来识别 Branch Performance Test 的跨度,同时考虑到 tr id 可以通过在
之间添加另一条记录来动态地保持更改为 11 或 12
//span[@class='fancytree-title' and text()='Branch Performance Test']/ancestor::span
以上将 return 具有条件的跨度的所有跨度祖先
或
//span[@class='fancytree-title' and text()='Branch Performance Test']/parent::span
以上将 return 具有条件的跨度的第一个跨度父级
<html>
<tr id="userman-orgchart-tree-node-9" class="fancytree-expanded fancytree-folder fancytree-has-children fancytree-exp-e fancytree-ico-ef">
<td>
<span class="fancytree-node" style="padding-left: 16px;">
<span class="fancytree-expander"></span>
<span class="fancytree-icon"></span>
<span class="fancytree-title">Legal</span>
</span>
</tr>
<tr id="userman-orgchart-tree-node-10" class="fancytree-active fancytree-folder fancytree-has-children fancytree-exp-c fancytree-ico-cf">
<td>
<span class="fancytree-node" style="padding-left: 16px;">
<span class="fancytree-expander"></span>
<span class="fancytree-icon"></span>
<span class="fancytree-title">Branch Performance Test</span>
</span>
</tr>
</html>
在这里,在上述情况下,我如何编写一个元素定位器来识别 Branch Performance Test 的跨度,同时考虑到 tr id 可以通过在
之间添加另一条记录来动态地保持更改为 11 或 12//span[@class='fancytree-title' and text()='Branch Performance Test']/ancestor::span
以上将 return 具有条件的跨度的所有跨度祖先
或
//span[@class='fancytree-title' and text()='Branch Performance Test']/parent::span
以上将 return 具有条件的跨度的第一个跨度父级