首页 > 解决方案 > 使用 Xpath 在 Automation Anywhere 中的特定行之后获取表的所有行

问题描述

我正在尝试使用 xpath 获取特定行之后的所有行的值(可以使用 id 标识此特定行)。请注意,我在自动化任何地方的对象克隆命令中使用它来定位和获取详细信息。假设这是表格:

<table class="actiontable" >
<tbody>
<tr></tr>
<tr></tr>
<tr id="h32423">
<td class="claim"><span id="claimants">Claimants</span></td>
</tr>
<tr id="a23">
<td id="g543"><a href="some site">Edward Hunter</a> </td>
</tr>
<tr>
<td id="g544"><a href="some site">Jane Doe</a> </td>
</tr>
<tr></tr>
</tbody>
</table>

在上表中,我需要获取 Claimants 行之后的所有名称。有什么建议么?

标签: xpathautomationanywhere

解决方案


I'm not sure whether it's too late to answer or not. I think the following XPath match your condition.

//tr[td[span[@id='claimants']]]/following-sibling::tr/td/a

*You can change /tr/td/a to /tr or /tr/td according to which element you want to access

I try this XPath in XPath Search console on Google Chrome and it navigate to all a tags after the row which has ID = claimants.

As I'm quite new to AA, I don't know how to loop through those a tags getting from the XPath. But I hope this help you solve the problem. :)

[Update] I found the solution
1. Using //tr[td[span[@id='claimants']]] with Object Cloning to get the index of the specific row. Let's say the index value is stored in variable $vIndex$
2. Loop through all td in the table
3. If the $Counter$ > $vIndex$ THEN that is the row under the specific row.


推荐阅读