好的,首先是代码:
<tr class="tableControlDataRow evenRow twTableTR">
<td class="twTableTD details" align="center" rowspan="2">
<td class="twTableTD details" align="center" rowspan="2">
<p>
<br>
**<p>**
<b>Model Number:</b>
QA GM 05132014 1038 Item 1 Model Number
</p>
<p>
<p>
<p>
<p>
</td>
<td class="twTableTD" align="center" rowspan="2">May-27-2014</td>
<td class="twTableTD" align="center">France</td>
<td class="twTableTD" align="center">Yes</td>
<td class="twTableTD" align="center">
<input id="hiddenCountryAuthorizationField0_0" type="hidden" name="tw#local#quoteComparison#0#country#0#authorizationStatusId#" value="0">
<input id="CountryAuthorizationYES0_0" class="qclCheckbox" type="checkbox" onclick="chooseAuthorization(0,0,'Yes','1')">
Yes
<br>
<input id="CountryAuthorizationNO0_0" class="qclCheckbox" type="checkbox" onclick="chooseAuthorization(0,0,'No','2')">
No
<br>
</td>
现在的问题...我通过执行以下操作找到了正确的起点
//p[contains(., "QA GM 05132014 1038 Item 1 Model Number")]
这让我看到了代码的 ** 部分。现在我需要遍历到 <tr class="tableControlDataRow evenRow twTableTR">
位于顶部,然后沿着链向下返回以单击
<input id="CountryAuthorizationYES0_0" class="qclCheckbox" type="checkbox" onclick="chooseAuthorization(0,0,'Yes','1')">
文本框。有什么建议吗?
最佳答案
首先找到 tr
,其中包含带有相应文本的 p
标记,然后转到所需的输入
:
//tr[.//p[contains(., "QA GM 05132014 1038 Item 1 Model Number")]]/td/input[@id="CountryAuthorizationYES0_0"]
请注意,这里肯定有多种编写 xpath 的方法。希望这个对您有用。
关于java - 另一个 Xpath 困境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23641263/