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.
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.