Get-clones | Listloop not reading all clones | Could not find instance from KeyProvided
In my automation I am using usekeys/get-clones, and with a listloop I want to read every clone. The listloop is not iterating though all the clones, but stops half way with an error message:
Could not find instance from Key Provider. KeyName: Key KeyProviderName: Rows
When I do the interrogation I can see that all the objects are matched, all the rows are being shown, I cannot see any difference between rows that are being yielded, and rows that are not being yielded with the listloop.
I've implemented serveral pauses to slow down the robot and give the method get-clones enough time, but speed is not the issue...
You're probably not waiting long enough for all of the clones to match. In your automation you are performing a WaitForCreate on one of the cells and providing a key of None. This means it will only wait for the first one. For some reason, you are performing a Rematch and then pausing for 2.5 seconds before you iterate the rows.
When handling clones like this, there's no specific event you can wait for to tell you that all of the clones are matched. If you have a label or something on the page that tells you how many there are, you can get the count of the clone collection and compare it to that value to see that they are all there. If they aren't, you can wait longer.
If you do not have a known value for how many there should be, then I prefer to just wait until the count stops changing. In either case, you'd have a loop very similar to what I describe below.
Add a ForLoop to your automation.
Set the limit of the forLoop to however many seconds you want to wait for the clones to all match.
You can change this later and I'll explain why, but this will keep things simple.
Add an integer variable to store the previous number of clones.
Before the forLoop, call GetClones on your control and extract a proxy.
From the proxy you can access the count. Store this in the "previous" variable.
Now trigger your forLoop.
On Yielded from the forLoop, pause for 1000 ms.
The limit multiplied by this pause duration will be how long this wait for.
I wouldn't set the pause any lower than 250 ms though to allow matching to occur and avoid breaking too early.
If you were to set it to 250 ms and wanted to wait for 30 seconds, you'd set the limit to 120 (120 X .25 seconds = 30 seconds).
Now call GetClones again and extract a proxy and the count.
Compare the count to the value in "previous".
If they are equal, you may break the loop.
If they differ, then update "previous" to equal the current count and allow the next iteration to occur.
I've found the solution. When you look at the matched rows in Get-clones.docx, my automation works when I make sure the first row is not matched. In my automation I am looking for an ID, and that row has no ID (first 3 digits).
You are right about making sure all the clones are matched, but in my scenario that was not the main bottleneck.