这是我的代码
<tr>
<td>
<div>
<span>Cloud Email Security</span>
<input id="productLine_software-0" name="productLine_software" value="Cloud Email Security" type="hidden"/>
</div>
</td>
<td>
<div>
<span>Core</span>
<input id="productCategory_software-0" name="productCategory_software" value="Core" type="hidden"/>
</div>
</td>
<td>
<div>
<span>Cloud Antispam</span>
<input id="softwareName_software-0" name="softwareName_software" value="Cloud Antispam" type="hidden"/>
</div>
</td>
<td>
<div>
<div>
<span>
<input id="select_boolean_software_1" type="checkbox" value="1" name="select_boolean_software"/>
</span>
</div>
</div>
</td>
</tr>
<tr>
<td>
<div>
<span>Cloud Email Security</span>
<input name="productLine_software" value="Cloud Email Security" type="hidden"/>
</div>
</td>
<td>
<div>
<span>Core</span>
<input id="productCategory_software-0" name="productCategory_software" value="Core" type="hidden"/>
</div>
</td>
<td>
<div>
<span>Cloud Email Security</span>
<input name="softwareName_software" value="Cloud Email Security" type="hidden"/>
</div>
</td>
<td>
<div>
<div>
<span>
<input id="select_boolean_software_1" type="checkbox" value="1" name="select_boolean_software"/>
</span>
</div>
</div>
</td>
</tr>
我在Selenium中使用此CSS选择器代码
css=tr:contains('Cloud Email Security & Content Control') input[type = 'checkbox']
它总是选择第一行而不是第二行。有什么想法吗?(我删除了restig标签,因为代码真的很长)
我使用CSS和XPATH进行了一些涉及tr标记的尝试,但在我看来tr在定位器中表现得很奇怪。
如果您不需要显式使用tr,而是可以在唯一输入之后使用复选框,请尝试以下操作
xpath=//input[@name='softwareName_software' and @value='Cloud Email Security']/following::input[@type='checkbox']
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句