【发布时间】:2016-02-27 05:30:27
【问题描述】:
我有一个包含一些行和列的表。我想选择名称为“Mobile”的下拉元素。名称在 col1 中,下拉列表在 col3 中 使用 XPATH 我可以找到名称“Mobile”,我需要到达 col3 以便我可以选择下拉元素。 我尝试使用“跟随”轴,但这会突出显示 col3 中的所有下拉元素。我很接近,我只需要获取属于 Name Mobile 的下拉列表。
这是我的 XPATH:
//table[@id="data_configuration_edit_mapping_tab_mappings_ct_mapping_body"]//td//div//span[text()="MOBILE"]//following::td//div//select
这是一些 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">
<tr class="GJPPK2LBEH GJPPK2LBGH" __gwt_subrow="0" __gwt_row="1">
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBHG">
<div __gwt_cell="cell-gwt-uid-307" style="outline-style:none;">
<input type="radio" name="rbCrossRow36"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-308" style="outline-style:none;">
<span title="PHONE" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">PHONE</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-309" style="outline-style:none;">
<select tabindex="-1">
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBBH">
<div __gwt_cell="cell-gwt-uid-310" style="outline-style:none;">
<input id="data_configuration_edit_mapping_tab_details_cb_phone" type="checkbox"/>
</div>
</td>
</tr>
<tr class="GJPPK2LBEH" __gwt_subrow="0" __gwt_row="11">
<td class="GJPPK2LBEG GJPPK2LBFH GJPPK2LBHG">
<div __gwt_cell="cell-gwt-uid-307" style="outline-style:none;">
<input type="radio" name="rbCrossRow36"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH">
<div __gwt_cell="cell-gwt-uid-308" style="outline-style:none;">
<span title="MOBILE" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">MOBILE</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH">
<div __gwt_cell="cell-gwt-uid-309" style="outline-style:none;">
<select tabindex="-1">
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH GJPPK2LBBH">
</tr>
<tr class="GJPPK2LBFG" __gwt_subrow="0" __gwt_row="12">
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBHG">
<div __gwt_cell="cell-gwt-uid-307" style="outline-style:none;">
<input type="radio" name="rbCrossRow36"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-308" style="outline-style:none;">
<span 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">
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBBH">
</tr>
<tr class="GJPPK2LBEH" __gwt_subrow="0" __gwt_row="13">
</tbody>
</table>
谢谢, 里亚兹
【问题讨论】:
标签: python-2.7 selenium xpath selenium-webdriver