如何基于同一表行中前一个单元格的值查找链接

时间:2018-10-12 06:31:28

标签: html selenium-webdriver xpath

我要在同一行中根据用户的电子邮件单击“单击以删除用户”链接,如下所示。请建议使用XPath或其他更好的选项来查找并单击使用Selenium Webdriver。

表行的HTML如下:

<tbody id="userlist">
<tr>
        <td>
        </td>
        <td>
            auser1@gmail.com
        </td>
        <td>
        </td>
        <td>
             Student
        </td>
        <td class="status-img">
            <a href="javascript:void(0);" data-toggle="tooltip" data-placement="top" title="" onclick="javascript:confirmUserStatusChange(1,&quot;/User/UpdateStatus?userId=70070&amp;status=3&amp;URLID=ipcenyi87att6vfqib7szg&quot;)" data-original-title="Click to disable user"><i class="fa fa-user fa-green fa-fw fa-2x"></i></a>
            <a href="javascript:void(0);" data-toggle="tooltip" data-placement="top" title="" onclick="javascript:user_editUser(&quot;/User/AddUser?userId=70070&amp;URLID=uazyqtod2f0w0oxqhjqasq&quot;)" data-original-title="Click to edit user"><i class="fa fa-pencil fa-fw fa-2x"></i></a>
            <a href="javascript:void(0);" data-toggle="tooltip" data-placement="top" title="" onclick="javascript:user_confirmDeleteUser(&quot;&quot;, &quot;/User/DeleteUser?userId=70070&amp;URLID=uazyqtod2f0w0oxqhjqasq&quot;)" data-original-title="Click to delete user"><i class="fa fa-times fa-fw fa-2x"></i></a>
        </td>
    </tr>

1 个答案:

答案 0 :(得分:0)

这应该工作:

//tr[td[normalize-space()="auser1@gmail.com"]]/td/a[@data-original-title="Click to delete user"]