I have a page with a list of check boxes. I want to click the check box which has a specified text. E.g. I want to click the check box which has the name "Use ocr variations" In the HTML the check box is above the Label tag. In firebug I can find the the label tag with the following XPath:
我有一个包含复选框列表的页面。我想单击具有指定文本的复选框。例如。我想单击名称为“Use ocr variations”的复选框。在HTML中,复选框位于Label标签上方。在firebug中,我可以使用以下XPath找到label标签:
//div[@id="match_configuration_edit_match_tab_data_objects_fp_flags"]//label[contains(text(), "Use ocr variations")]
I would like to go 1 above to the input tag which has the check box. I have tried to use ancestor but that does not work
我想在输入标签上面输入1,其中包含复选框。我试图使用祖先,但这不起作用
//div[@id="match_configuration_edit_match_tab_data_objects_fp_flags"]//label[contains(text(), "Use alias list to get variations")]/ancestor::input
What is the Xpath or CSS i could use to get to the checkbox?
什么是我可以用来进入复选框的Xpath或CSS?
The HTML is:
HTML是:
<div id="match_configuration_edit_match_tab_data_objects_fp_flags">
<div class="gwt-Label matchruleheader">Gender and title flags</div>
<span class="gwt-CheckBox" style="display: block;">
<span class="gwt-CheckBox" style="display: block;">
<span class="gwt-CheckBox" style="display: block;">
<div class="gwt-Label matchruleheader">Name flags</div>
<span class="gwt-CheckBox" style="display: block;">
<span class="gwt-CheckBox" style="display: block;">
<div class="gwt-Label matchruleheader">Other flags</div>
<span class="gwt-CheckBox" style="display: block;">
<span class="gwt-CheckBox" style="display: block;">
<input id="gwt-uid-512" type="checkbox" value="on" tabindex="0" checked=""/>
<label for="gwt-uid-512">Use alias list to get variations</label>
</span>
<span class="gwt-CheckBox" style="display: block;">
<input id="gwt-uid-513" type="checkbox" value="on" tabindex="0" checked=""/>
<label for="gwt-uid-513">Use ocr variations</label>
</span>
</div>
note: input id for the checkbox is a dynamic value. I cannot use that one. input id="gwt-uid-513" Thanks, Riaz
注意:复选框的输入ID是动态值。我不能用那个。输入id =“gwt-uid-513”谢谢,Riaz
1 个解决方案
#1
1
ancestor is for parent/grant parent elements. As the 'input' elemet you are looking for in the same level, you can use preceding
.
祖先用于父/授予父元素。作为您在同一级别寻找的“输入”元素,您可以使用前面的。
#1
1
ancestor is for parent/grant parent elements. As the 'input' elemet you are looking for in the same level, you can use preceding
.
祖先用于父/授予父元素。作为您在同一级别寻找的“输入”元素,您可以使用前面的。