鑑於這種HTML:的XPath - 如何找到信息
<tr class="even" id="district_22">
<td class="name">Virginia Beach City Public Schools</td>
<td class=""><a href="/admin/districts/22" class="member_link delete_link" data-confirm="Sure?" data-method="delete" rel="nofollow">Delete</a></td>
</tr>
<tr class="even" id="district_23">
<td class="name">Virginia City City Public Schools</td>
<td class=""><a href="/admin/districts/23" class="member_link delete_link" data-confirm="Sure?" data-method="delete" rel="nofollow">Delete</a></td>
</tr>
<tr class="even" id="district_24">
<td class="name">Virginia Town City Public Schools</td>
<td class=""><a href="/admin/districts/24" class="member_link delete_link" data-confirm="Sure?" data-method="delete" rel="nofollow">Delete</a></td>
</tr>
我試圖使用Selenium和XPath它。 我在嘗試選擇屬於'Virginia Beach City Public Schools'的'刪除'鏈接時遇到了問題。 我是xpath新手。
我想:
xpath=(//td[text()='Beach')]/@class.contains('delete'))
但沒有找到的元素。
注意:我不能使用ID,因爲這些是重複測試,ID每次都會更改。
只是爲了解釋這是怎麼回事...中的XPath的第一位選擇包含'沙灘'的td。然後,它選擇td的父節點,然後從中選擇包含具有包含'delete_link'類的鏈接的任何td。希望能夠說清楚! –