This is working correctly.
I then created a foreach loop that loops through the items in the collection and call a click action on the item.
On the first item, the click works as intended. The bot then clicks the back button on the opened website. On the second and all subsequent iterations, the following error is thrown:
The UiElement is no longer valid
I assume this has to do with leaving the page and coming back to the page, but I am not sure. I am very new to UiPath (2-3 weeks of playing around) so it could be something easy I am overlooking.
Like @muhammedyuzuak mentioned, most likely your selectors are changing or different when you navigate back to the page.
It could also be that the elements are not yet loaded/active when it is attempting second iteration.
Try these debugging steps:
After you build your collection of UIElements, loop through and write the selectors to console. Compare these against the selectors from UIExplorer to determine if the selectors have changed after page navigation.
Since you are working with a table, you might be able to use idx to click the link on a specific row.
Note: Usage of idx is generally not recommended and should only be used if all other options have been exhausted.