For each UI Element that adjusts during runtime

I have a very simple For Each Ui Element activity that has a few clicks throughout a single iteration. At the end of each iteration however, one item in the collection (obviously the first item) will get automatically achieved, thus removing it from my collection. With that, my bot never makes it to the second iteration as the collection “is no longer the same”.

How can I get this collection to be dynamic each iteration until there are no more items in the collection upon last iteration?

if you want to make it dynamic, I recommend you to use idx in selector or find children activity.

  1. use idx in selector
  • make idx an argument in selector. and give the idx argument in a loop.
  • then you can control the idx value.
  1. use find children.
  • in each iteration, use find children.

good luck with your project and happy automation

@chris.bartkewicz
Have a copy of the collection stored in a different variable that you are using in the for each ui element activity, remove items from this collection using invoke method once done.

@chris.bartkewicz

You mean on ui would the first row be removed and that is causing the issue?

If so ideally you need the first item always irrespective of the number of items and loop iteration

If that is the case then identify a unique selector for the first element which does not depend on the value but the position..then in loop you can use the same selector to perform all steps and use check app state to check if there is first item then continue else end the loop

So basically you would be using a static selector which works for any first item

Cheers

I thought about this as a solution, however, every first item in the ui collection in the first row disappears as it is a ticket item that will be resolved in each iteration.

What would an argument look like using the inx selector? like make the index value a wildcard so that it loops regardless of the current value of items in the collection?

@chris.bartkewicz

yes the first item is removed but the gneric selector of first item will remain same if you dont use innertext kind of attributes

so each iteration selector will be same but what selector retrieves would be different

cheers

Question, what do you mean by generic selector?

If the page is changing each time and the item you processed disappears, you shouldn’t use For Each UI Element. You should use a Do While and inside it handle the first item in the list. Use a Check App State to make sure there is an item visible, and use its output in the Do While condition so it’ll stop looping when there are no more items.

1 Like

@chris.bartkewicz

Means a selector which contains details about first row but not details about the items in first row..that way ay item as first row is highlighted

Cheers

darn, I see what you mean, but every column in the first row is a unique value. Not sure how to snag something generic.

Not a bad idea, while try!

@chris.bartkewicz

Generally table name ,tablerow number tablecol number they remain constant can tey with them

Cheers