0

我正在尝试使用 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 行之后的所有名称。有什么建议么?

4

3 回答 3

0

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.

于 2019-01-10T08:11:16.033 回答
0

对于您的简单示例,您可以在 Automation Anywhere 编辑器中执行以下操作:

添加Times条件为的循环命令2

在循环对象内克隆您要访问的字段之一并将其更改DOMXPath

/html/body/table[1]/tbody[1]/tr[$Counter$+3]/td[1]/a[1]

选择Action成为Get Property并将Select PropertyHTML InnerText 分配给您选择的变量

通过消息框命令输出此变量

运行时,您应该会看到显示的两个名称。

在此我们使用 AA 计数器变量来遍历 DOMXPath。<tr>我已将其调整了 3,因为在您希望开始的行之前有 3 个标签

于 2018-11-15T09:36:58.487 回答
0

您需要preceding-sibling像这样检查数据:

//tr[preceding-sibling::tr[normalize-space(.)='Claimants']]

您可以根据您的评论尝试此操作:

/table[@class='actiontable']/descendant::tr[normalize-space(lower-case(.))!= 'claimants']
于 2018-11-15T09:18:50.537 回答