【发布时间】:2023-03-21 23:19:01
【问题描述】:
我有一个 5 列的表格。第 2 列有一些名称文本。第 1 列是一个单选按钮。第 3、4 和 5 列是一个单选按钮。 我想从名称文本为“MaidenName”的第 3 列中选择单选按钮
我可以找到 MaidenName,然后我尝试使用 follow-sibling 转到下一列。我的 XPATH 不工作。
我的 XPATH 是:
//table[@id="data_configuration_edit_mapping_tab_mappings_ct_mapping_body"]/tbody//tr//td//div//span[text()="MAIDENNAME"]/following-sibling::td[2]//div//span[@type="radio"]
HTML 示例是:
<table id="data_configuration_edit_mapping_tab_mappings_ct_mapping_body" cellspacing="0"
style="table-layout: fixed; width: 100%;">
<colgroup>
<tbody>
<tr class="GJPPK2LBFG" __gwt_subrow="0" __gwt_row="0">
# few trs here. I have removed. too long to paste otherwise
<tr class="GJPPK2LBFG" __gwt_subrow="0" __gwt_row="12">
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBHG">
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1076" style="outline-style:none;">
<span class="" title="DOB"
style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">DOB</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1077" style="outline-style:none;">
<input type="radio" name="rb3386"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1078" style="outline-style:none;">
<input type="radio" name="rb3386"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBBH">
<div __gwt_cell="cell-gwt-uid-1079" style="outline-style:none;">
<input type="radio" checked="" name="rb3386"/>
</div>
</td>
</tr>
<tr class="GJPPK2LBEH" __gwt_subrow="0" __gwt_row="13">
<td class="GJPPK2LBEG GJPPK2LBFH GJPPK2LBHG">
<div __gwt_cell="cell-gwt-uid-1075" style="outline-style:none;">
<input type="radio" name="rbCrossRow119"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH">
<td class="GJPPK2LBEG GJPPK2LBFH">
<td class="GJPPK2LBEG GJPPK2LBFH">
<td class="GJPPK2LBEG GJPPK2LBFH GJPPK2LBBH">
</tr>
<tr class="GJPPK2LBFG GJPPK2LBMG" __gwt_subrow="0" __gwt_row="14">
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBHG GJPPK2LBNG">
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBNG">
<div __gwt_cell="cell-gwt-uid-1076" style="outline-style:none;">
<span title="MAIDENNAME"
style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">MAIDENNAME</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBNG">
<div __gwt_cell="cell-gwt-uid-1077" style="outline-style:none;">
<input type="radio" name="rb3388"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBNG">
<div __gwt_cell="cell-gwt-uid-1078" style="outline-style:none;">
<input type="radio" name="rb3388"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBBH GJPPK2LBNG">
<div __gwt_cell="cell-gwt-uid-1079" style="outline-style:none;">
<input type="radio" checked="" name="rb3388"/>
</div>
</td>
</tr>
<tr class="GJPPK2LBEH" __gwt_subrow="0" __gwt_row="15">
<tr class="GJPPK2LBFG" __gwt_subrow="0" __gwt_row="16">
</tbody>
</table>
找到 MaidenName 后,我想向下 2 列并从 MaidenName 中选择第 2 列中的单选按钮
谢谢,里亚兹
【问题讨论】:
标签: python-2.7 selenium xpath selenium-webdriver