For Each Tag & For Each Tag Path
Hi All,
Most of the robot developers are initially confused about the difference between the For Each Tag and For Each Tag Path actions steps in kapow katalyst. Both action steps are similar functionalities but a small difference. Here a small discriptions for these two action steps.
For Each Tag
The For Each Tag action loops through a group of tags. In each iteration, the appropriate tag is marked as a named tag.
Most often, the loop should loop from the beginning to the end, such as looping through all the <tr>-tags of a table. However, it is also possible to configure the For Each Tag action to loop through only some of the tags, such as the last n tags in a sequence.
The For Each Tag action is similar to the For Each Tag Path action. The main difference is that the For Each Tag action only finds the immediate children of the found tag, whereas the For Each Tag Path action searches the entire subtree.
Consider this found tag,
- Code:
<table>
<body>
<tr>First Tag</tr>
<tr>Second Tag</tr>
<tr>Third Tag</tr>
</body>
</table>
With Tag Name set to "tr", First Tag Number set to 0 (From First), and Last Tag Number set to 1 (From Last), the For Each Tag action will loop through <tr>-tags 0, 1, 2, and 3. In each iteration, the named tag set by the action will be the appropriate <tr>-tag as shown below,
Iteration - Named tag
1 - <tr>-tag 0
2 - <tr>-tag 1
3 - <tr>-tag 2
For Each Tag Path
The For Each Tag Path action loops through all tags of a given type in the subtree of the found tag. In each iteration, the appropriate tag is marked as a named tag.
The For Each Tag Path action is very similar to the For Each Tag action. The main difference is that the For Each Tag action only finds the immediate children of the found tag whereas the For Each Tag Path action searches the entire subtree.
Consider this found tag,
- Code:
<table>
<tbody>
<tr>
<td> 1 </td>
<td> 2 </td>
<td> 3 </td>
</tr>
</tbody>
</table>
Set the Tag Path to td. The first iteration will set a named tag to <td> 1 </td> and in the next iteration, the named tag will be <td> 2 </td>
Now consider this found tag:
- Code:
<table>
<body>
<tr>
<td>
<table>
<tbody>
<tr>
<td> 1 </td>
<td> 2 </td>
</tr>
</tbody>
</table>
</td>
<td> 3 </td>
</tr>
</body>
</table>
Set the Tag Path to tr.td. The first iteration will set a named tag to
<td><table><tbody><tr><td> 1 </td><td> 2 </td></tr></tbody></table></td>
and in the next iteration, the named tag will be
<td> 3 </td>
Screenshot for For Each Tag, Screenshot for For Each Tag Path,
Expect your feedback and suggestions..
Regards,
Shyam Kumar