What I need to find is the "Edit" link that coincides with the "Test Group" link.
I have tried:
//td[contains(text(),'Edit')]/..//a[text()='Test Group']
//td[contains(., "Edit")]/preceding-sibling::a
//*[contains(text(),'Edit')]//tr/td[contains(., 'Test Group')])[3]
Source HTML:
<td>
<a class="hovsml" onclick="editGroup(5522); return false;" href="#">Edit</a>
</td>
<td>
<a class="hovsml" onclick="removeGroup(5522,'Test Group'); return false;" href="#">Delete</a>
</td>
<td>
<img id="groupText5522" width="16" vspace="0" border="0" hspace="0" height="16" onmouseout="hideGroupList('groupInfoDiv5522');" onmouseover="showGroupList('groupText5522','groupInfoDiv5522');" src="img/group_info.gif" style="position: relative;"/>
<a class="hovsml" title="Test Group" onclick="popup('GroupInfo.php?id=5522','groupinfo',300,430); return false;" href="#">Test Group</a>
</td>
答案 0 :(得分:1)
最强大的方法可能是从包含&#34;测试组&#34;的所有&lt; tr&gt;开始。链接并找到&#34;编辑&#34;从那里链接:
tr[.//a[text()='Test Group']]//a[text()='Edit']
(假设所有&lt; td&gt;都有&lt; tr&gt;父母。)
答案 1 :(得分:0)
从&#34;测试组开始&#34;链接,上升两个级别,然后寻找&#34;编辑&#34;链接:
//a[text()='Test Group']/../../td/a[text()='Edit']