我目前正在工作的java/selenium webdriver自动化。不过,我被困在这个特定的部分,我无法使webdriver点击复选框基于值。 ();}}。点击();}();}}。点击();硒webdriver - 点击复选框基于表值
它工作的时候我没有使用XPath的轴部分,但它只能选择第一个复选框
下面是HTML
<tr class="even">
<td style="width: 20px;">
<input class="chkPopupCod" type="checkbox">codData=Object { id=101914, codId=101906, label="AAA", more...}
</td>
<td class="" align="left">AAA</td>
</tr>
<tr class="odd">
<td style="width: 20px;">
<input class="chkPopupCod" type="checkbox" style="background-color: rgb(255, 255, 255);">codData=Object { id=101918, codId=101907, label="BBB", more...}
</td>
<td class="" align="left" style="background-color: transparent;">BBB</td>
</tr>
<tr class="even">
<td style="width: 20px;">
<input class="chkPopupCod" type="checkbox">codData=Object { id=101922, codId=101908, label="CCC", more...}
</td>
<td class="" align="left">CCC</td>
</tr>
太棒了!它的作品 'driver.findElement(By.xpath(“// td [contains(text(),'BBB)]/preceding-sibling :: td/input [@ class ='chkPopupCod']”))。click ();' 非常感谢Arran! – user2853922