My application has a table with a "Status" column. I am using "Evaluate JS on Object" to scan the column to determine if any of the rows is in "Pending" status and take the appropriate action. The object identification works fine, as TruCLient highlights all items in the column:
What I am trying to do is similar to web_reg_save_param in the HTTP protocol that returns an array when more than one match exists. The problem is that, instead of returning an array of objects, TruClient fails with "multiple objects were found that are similar to the target object".
<table>
<thead>
<tr>
<th>Details</th>
<th>Number</th>
<th>Status</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="/001">View</a></td>
<td>20-001</td>
<td>Completed</td>
<td>01/01/2020</td>
</tr>
<tr>
<td><a href="/002">View</a></td>
<td>20-002</td>
<td>Cancelled</td>
<td>01/02/2020</td>
</tr>
<tr>
<td><a href="/003">View</a></td>
<td>20-003</td>
<td>Cancelled</td>
<td>01/03/2020</td>
</tr>
</tbody>
TruClient step operates on a single object. In case you would like to iterate over the elements and perform an action for each object, it would require multiple script steps:
Find out how many elements exist with the required status - you could use an "Evaluate JavaScript" step to evaluate an XPath with count and store it to variable. Something like:
Add a for loop step from 1 to statusCount (including).
Inside the for loop step, add 'Generic Object Action' step with JavaScript ID Method and the following code
ArgsContext.i allows you to access variable "i" defined in the for loop from within Object Identification section of the step.