<tr id="Any_22" class="value-table list-row-even">
<td class="selection-column">
<input id="Checkbox_1_1" type="checkbox" onclick="doCheck( this, 'value-table-selected', 'value-table' )" name="Checkbox_1_1">
</td>
<td id="columnValues_19" class="first-selection" onmouseover="sCC(this)">
<span>
<table id="container_7" class="vo-label" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="skinImage">
<img border="0" src="/images/icons/small/pawn_glass_white.gif">
</td>
<td id="Any_23" class="remainder"> I_am_here </td>
</tr>
</tbody>
</table>
</span>
</td>
</tr>
如果我只知道“I_am_Here”txt,如何单击该复选框。
我已经尝试过 //td[normalize-space(text())='192.168.9.2']
。但它对我不起作用。
最佳答案
这是一种适用于发布的 HTML 代码段的可能 XPath:
//tr[td[normalize-space()='I_am_here']]/td/input[@type='checkbox']
简要说明:
//tr[td[normalize-space()='I_am_here']]
:查找tr
其中td
子元素具有内部文本等于“I_am_here”
/td
:从这样的tr
中,找到子元素td
/input[@type='checkbox']
:从这样的td
中,返回input
元素,其中type
属性值等于"checkbox"
输出:
<input id="Checkbox_1_1" name="Checkbox_1_1" onclick="doCheck( this, 'value-table-selected', 'value-table' )" type="checkbox"/>
关于java - 如果我只知道使用 xpath 的代码中的一些文本,我怎样才能找到该复选框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34409780/