Better understanding of the ForEachUiElement activity. (Indexing)

First post here but I’ve been struggling trying to understand this a little bit better. I use a ForEachUiElement activity to run through a list of clients where the bot clicks one, performs task, moves onto next element/client.

All of this works great but the site that it is on has very strict time policies and therefor the activity only completes like 30 of the clicks and then the page is timed out, or at times just another error appears out of the wild.

What I am trying to figure out is, if an error or timeout occurs, how do I index the currentElement so I can break from the loop handle the error and then continue with the same Element that was interrupted? You can’t use .index or CurrentElement(x) because it will say something along the lines of “Elements can’t be indexed” which is the part I’m having a hard time understanding. That’s fine if an element itself can’t be indexed but what about the actual loop activity? How does that keep track of each element and progress to the next if there is no index?

I even tried to create a collection from the elements in the ForEachUiElement activity the tried to loop through it with a regular ForEach (because it has a CurrentIndex option under properties) but when you try to apply that to the element that needs to be chosen. (e.g. start at the 5th instead of the 1st) it tells me elements can’t be indexed.

Anyone able to enlighten me on this? or am I missing something simple.

You’d have to store the index of the last item processed, and use an If inside the FEUE to skip until that stored index is reached.

As an alternative, how about just making it do something in the original page so the session doesn’t time out?

So something like this? lets say start at 5

if CurrIndex>=4
do task

Maybe not exactly but a manual index is what you mean?

Also, It uses the original page the whole time expcept the popup download window. The site just limits your time that you’re logged in essentially.

I like your idea and I played around with a similar setup but I was hoping there was an actual built in index. (there almost has to be shouldn’t it?) While this will most likely work, I want to wait to see if anyone has anymore clarification of the how the actual loop keeps track and maybe a way to harness that power before I mark as solution.

Thank you!

There is a built-in index for FEUE (CurrentIndex) but you have to store it in a variable so you can get back to it when you repeat the FEUE. Yes the If you showed as an example is what I meant. If CurrentIndex >= StoredLastIndexProcessed so as the last thing you do inside the FEUE, Assign StoredLastIndexProcessed = CurrentIndex

Alright then. That’s what I’ll do. I saw the CurrentIndex for the normal FE activity but not the FEUE. Maybe it just isn’t listed in the properties window. I appreciate the help!

Correct, it’s not listed it’s just automatic. It’s not even in the documentation, I stumbled on it by accident.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.