【发布时间】:2014-07-01 19:20:04
【问题描述】:
我正在尝试根据其相邻文本单击复选框。然而,页面结构使它变得相当困难。问题是事物嵌套在嵌套在 div 等中的表中。有问题的代码部分如下所示:
<tr id="yui-rec62" class="yui-dt-first yui-dt-even" style="">
<td class="yui-dt25-col-access yui-dt-col-access yui-dt-first" headers="yui-dt25-th-access ">
<div class="yui-dt-liner">
<input id="functionId13" type="checkbox" value="13" name="functionId">
</div>
</td>
<td class="yui-dt25-col-name yui-dt-col-name yui-dt-last" headers="yui-dt25-th-name ">
<div class="yui-dt-liner">Ability to Add/Remove Queues</div>
</td>
</tr>
我需要能够通过 ID 为 functionId13 的输入找到包含 Ability to Add/Remove Queues 的 div。这导致了这样的检查:
if(div has text of "Ability to Add/remove Queues"){
return the WebElement of the check box associated with it
}
我有一个所有复选框及其 ID 的列表,我只是想不出一种方法来将它们与它们的描述性文本相匹配。
【问题讨论】:
-
你用什么语言编写这个代码? XPath 应该能够做到这一点。
标签: java selenium css-selectors