我有一个带有复选框列表的页面。我想单击具有指定文本的复选框。例如,我想单击复选框,它的名称是“使用ocr变体”,在HTML中,复选框位于标签标签的上方。在firebug中,我可以使用以下XPath找到标签标记:
//div[@id="match_configuration_edit_match_tab_data_objects_fp_flags"]//label[contains(text(), "Use ocr variations")]我想去上面的输入标签,其中有复选框。我试过使用祖先,但这行不通。
//div[@id="match_configuration_edit_match_tab_data_objects_fp_flags"]//label[contains(text(), "Use alias list to get variations")]/ancestor::input我可以使用什么Xpath或CSS来获取复选框?
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>注意:复选框的输入id是一个动态值。我不能用那个。输入id="gwt-uid-513“谢谢,Riaz
发布于 2015-10-06 16:16:58
祖先用于父/授予父元素。作为您在同一级别上寻找的“输入”元素,您可以使用preceding。
https://stackoverflow.com/questions/32974586
复制相似问题