Clicking on element found in for loop, outside of the for loop



This may sound confusing, but it is a specific issue I have run into. I am using a for each loop to go through elements (found using find children activity) of an html table and check them against a variable. If they are equal to that variable, it adds one to a count. However, after the for loop, if the count is equal to 1, I want to go back to that same child element that was the iterator and click on it.

This is a problem because the child iterator is only in the scope of the for each loop, but the click needs to be a generic variable so the program can be used repeatedly. Does anybody have a best practice for this specific issue?



Would be easier to give a more specific opinion if you’d post some screenshots or an example… I’ll give it a shot anyway: create an In argument that holds the initial variable with which you compare your child so that you can reuse the .xaml and insert that variable in the click’s selector.


when your condition is met, use a ‘Find element’ activity which will have as output an uielement let’s call it element1, then, when the for loop is over, use the click activity specifying element1 in element section.


You could assign the item from the loop to a variable that can be accessed outside of that loop.