Question

Web automation: Choosing a link in a table section during a for loop

I'm new to robotic automation. I've reviewed all the training materials I can find on HTML tables and keys/indexes, but I don't feel I understand the topic. So I'm not sure how to phrase this question, but I'll try:

The site I am automating has a table with one header row (match cells) and one table section of data cells. I have designed this in the HTML table designer. One cell in each data row contains a hyperlink. I've matched the hyperlink such that it appears inside the table section and matches all rows in the table section.

I have a for loop iterating over the table section. The logic is to click the link on the first row that meets the conditions. The conditions are evaluated in a C# script. So when the script returns true, the for loop breaks and attempts to return the index at which it broke. This is not working. There are two rows in the table section, and the for loop returns 2 (the second row is the one that meets the condition). I think it should be returning 1.

Secondly, I'm trying to have the automation pick the correct link given the index. It doesn't like 2 (index out of range, naturally). However, I've tried forcing the absolute index to be 1, just to see if that works, and it doesn't. It just clicks the link in the first row.

There is a key involved, but I'm not sure what that is. I think I can use the Query property? There isn't documentation about how to use that. I'd like to use Query to pick a specific absolute index??

Please help. This is a big mess and I don't know how to do this.

Correct Answer
November 13, 2018 - 7:57am

Ok, so let's fix few things here. First of all, do not put multiple execution yellow lines from single point. Automation doesn't know what to do in this case. This happens after Yielded on forLoop1 and I think this is why you get incorrect result. If you want to read both, StartDate and ExpirationDate, connect ExpirationDate after StartDate, but not directly from Yielded. Same applies to Exit point block. 

You can actually call PerformClick right inside the loop after condition is met and call Break to stop the loop.

Here is an illustration for the items mentioned above:

If you want to pass Index further, you can store current Index on each iteration into dedicated variable outside a loop and pass variable value after Break is executed.

If you use Absolute Index, you don't need to use Key. Key is autogenerated identifier for each instance of cloned control (tableSection2 is a cloned control in your case). It can be used with ListLoop in the similar manner and makes automation a bit easier and readable, but Absolute Index+ForLoop is fine as well.

Comments

Keep up to date on this post and subscribe to comments

November 8, 2018 - 4:02am

Hi,

Could you post a screenshot of your automation, HTML table and table designer view (and URL of the web page with the table if it is publicly available)?

November 12, 2018 - 10:19am

The website is only accessible to logged-in accounts.

I've attached screenshots of the table mapping and the two automations that are determining the correct row and attempting to click the link in that row. 

November 13, 2018 - 7:57am
Response to StephanieG8434

Ok, so let's fix few things here. First of all, do not put multiple execution yellow lines from single point. Automation doesn't know what to do in this case. This happens after Yielded on forLoop1 and I think this is why you get incorrect result. If you want to read both, StartDate and ExpirationDate, connect ExpirationDate after StartDate, but not directly from Yielded. Same applies to Exit point block. 

You can actually call PerformClick right inside the loop after condition is met and call Break to stop the loop.

Here is an illustration for the items mentioned above:

If you want to pass Index further, you can store current Index on each iteration into dedicated variable outside a loop and pass variable value after Break is executed.

If you use Absolute Index, you don't need to use Key. Key is autogenerated identifier for each instance of cloned control (tableSection2 is a cloned control in your case). It can be used with ListLoop in the similar manner and makes automation a bit easier and readable, but Absolute Index+ForLoop is fine as well.

November 16, 2018 - 3:26pm

Thank you so much! Your reply was packed with helpful information. I have this process working now.