我有一个单击元素后显示的对话框。在此对话框中,有2个表格(HTML)。表格中的表格。表1具有文本“匹配审核代码”。表2具有一些行和列。第1列有一个复选框。第2列具有char值,例如字母“ I”。 第3列具有一些文本,例如“与完整地址匹配”
我想从第1列中找到复选框,该复选框的文本描述为“匹配完整地址”,而父表的文本为“匹配审核代码”
我尝试了以下Xpath,该Xpath定位了具有文本“与完整地址匹配”的复选框
//div[contains(text(), "Matched to full address")]/ancestor::tr[1]/td[1]//input
我的Selenium Python脚本不会单击此复选框。开发人员说,某处的HTML中可能有1个以上的“匹配完整地址”。
我需要Xpath从具有文本“匹配审核代码”的父表开始,然后转到具有文本“匹配完整地址”的下一个表,然后找到该复选框。
我该如何构建Xpath?
HTML是:
<table class="GJPPK2LBAL" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="left" style="vertical-align: top;">
<div class="GJPPK2LBPK">Match audit codes</div>
</td>
<td align="left" style="vertical-align: top;">
<button class="gwt-Button GJPPK2LBLK" type="button">X</button>
</td>
</tr>
</tbody>
</table>
<table class="GJPPK2LBOK" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="left" style="vertical-align: middle;">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<tr>
<td align="left" style="vertical-align: top;">
<div style="overflow: auto; position: relative; width: 25em;">
<div style="position: relative;">
<table class="GJPPK2LBJE" cellspacing="0"
__gwtcellbasedwidgetimpldispatchingfocus="true"
__gwtcellbasedwidgetimpldispatchingblur="true">
<thead aria-hidden="false">
<colgroup>
<tbody>
<tr class="GJPPK2LBCD" __gwt_subrow="0" __gwt_row="0">
<td class="GJPPK2LBBD GJPPK2LBDD GJPPK2LBED">
<div __gwt_cell="cell-gwt-uid-5972" style="outline-style:none;">
<input type="checkbox" tabindex="-1"/>
</div>
</td>
<td class="GJPPK2LBBD GJPPK2LBDD">
<div __gwt_cell="cell-gwt-uid-5973" style="outline-style:none;">I</div>
</td>
<td class="GJPPK2LBBD GJPPK2LBDD GJPPK2LBOD">
<div __gwt_cell="cell-gwt-uid-5974" style="outline-style:none;">Matched to
full address
</div>
</td>
</tr>
<tr class="GJPPK2LBCE" __gwt_subrow="0" __gwt_row="1">
<td class="GJPPK2LBBD GJPPK2LBDE GJPPK2LBED">
<div __gwt_cell="cell-gwt-uid-5972" style="outline-style:none;">
<input type="checkbox" tabindex="-1"/>
</div>
</td>
<td class="GJPPK2LBBD GJPPK2LBDE">
<div __gwt_cell="cell-gwt-uid-5973" style="outline-style:none;">B</div>
</td>
<td class="GJPPK2LBBD GJPPK2LBDE GJPPK2LBOD">
<div __gwt_cell="cell-gwt-uid-5974" style="outline-style:none;">Matched to
building
</div>
</td>
</tr>
<tr class="GJPPK2LBCD" __gwt_subrow="0" __gwt_row="2">
<tr class="GJPPK2LBCE" __gwt_subrow="0" __gwt_row="3">
</tbody>
<tbody style="display: none;">
<tfoot style="display: none;" aria-hidden="true"/>
</table>
谢谢,里亚兹
我不确定是否收到您的问题。您要查找包含“匹配审核代码”的表,然后移至下一个包含“匹配完整地址”的表,然后在该表内部搜索与“匹配完整地址”文本相同的行中的复选框?
如果是这样,则它应如下所示:
//table[.//div[text()='Match audit codes']]/following-sibling::table[.//div[.='Matched to full address']][1]//div[.='Matched to full address']/ancestor::tr[1]/td//input[@type='checkbox'][1]
如果.='Matched to full address'
不起作用,请尝试contains(.,'Matched to full address')
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句