【发布时间】:2017-03-02 02:57:26
【问题描述】:
<table width="100%" cellpadding="2" border="0" cellspacing="0">
<tbody>
<tr>
<tr>
<td valign="top" align="left" style="width:2%">
<input id="ucRightAdd_grdList_ctl04_chkSelect" type="checkbox" name="ucRightAdd$grdList$ctl04$chkSelect">
</td>
<td width="65%" valign="top">
<span class="BodyText"> Workflow View </span>
</td>
在上面的 html 代码中,我需要选中文本 Workflow View 对应的复选框。我为此使用了以下代码,但它不起作用:
Driver.findElement(By.xpath("//span[contains(., \"" +rightName+ "\")]../preceding-sibling::/td/input[@type='checkbox']")).click();
【问题讨论】:
标签: html xpath selenium-webdriver