xpath - 如何在给定的表行中查找删除链接?

时间:2012-12-05 18:13:15

标签: selenium xpath

鉴于以下HTML,如何找到删除链接?

我已经能够选择行:

//td[contains(text(),'DeleteMe')]/../../tr

但我似乎无法找到一种方法来选择删除按钮。

例如我试过:
 //td[contains(text(),'DeleteMe')]/../../tr//a[@class='delete_link']但它没有选择链接。

我无法使用ID的403,113,112等,我需要一个没有实际ID的脚本进行重新测试。

<tr class="odd" id="activity_403">
  <td class="name">DeleteMe</td>
  <td class="direct">false</td>
  <td class="">
    <ul>
      <li><a href="/admin/roles/113/edit">Language Therapist</a></li>
      <li><a href="/admin/roles/112/edit">Speech Therapist</a></li>
    </ul>
  </td>
  <td class="">
    <a href="/admin/activities/403" class="member_link view_link">View</a>
    <a href="/admin/activities/403/edit" class="member_link edit_link">Edit</a>
    <a href="/admin/activities/403" class="member_link delete_link" data-confirm="Are you sure you want to delete this?" data-method="delete" rel="nofollow">Delete</a>
  </td>
</tr>

1 个答案:

答案 0 :(得分:0)

找到它:

//td[contains(text(),'DeleteMe')]/../../tr//a[contains(@class,'delete_link')]