I am writing an automation for a webpage where i search for a voucher ID, and download any attachments belonging to that ID. I have a control interrogated to match all the menu buttons of the attachments so that i can click on them and then click the download button one by one. However, when i click through the first download, it causes the page to refresh and the GetClones collection no longer seems to be matched for the second iteration of the loop. I keep getting the "Unable to find contextId for key: 00000000000" message between the GetClones method and the ListLoop.
There is no way to independently and dynamically match these menu buttons for every page, so iterating through the clones is the only way i can see of accomplishing this. Any ideas on how i can continue iterating through a collection from GetClones when the page refreshes after the first loop iteration? I have attached screenshots of the error and the process flow.
You cannot iterate a collection if that collection changes during iteration. In cases like this that I have worked on, I would look for some indicator in each of the clones controls that clues you in to its "index" or some other unique way to identify it whenever the page loads. For example; I have seen that sometimes the ElementID of each of the images contains an index at the end (or inside it). You could iterate the initial clone collection and capture all of those in a lookup table. Then you could iterate the lookup table since that won't change. With each iteration, you'd locate the matching clone from the collection, click it, perform the download, wait for the clone collection to rematch, and then return to the loop.