Dynamic Selectors in For Each UiElement activity

I am using a For Each UiElement activity. There are about 300 elements that the process goes through. Occasionally, the screen on which the elements appear, takes too long to load and the activity times out. I have added a longer timeout period but I would also like the bot to refresh the page when it can’t find the next element.

Refresh gets the screen to come back, however the “CurrentElement” variable then changes because of the new session ID within the attributes. How can I make the “CurrentElement” variable, within the for each UiElement activity, dynamic?

Here is a screenshot with what the CurrentElement variable looks like. It’s the highlighted bit that is changing when the page is refreshed.

Hey @kasey.betts you can use check app Estate activity and if the element not found simply use Refresh Browser activity.and also try to use Retry activity instead of increasing he timeout.
cheers

Yes, this is what I am doing. I use check app state and then when false I refresh. The element then appears but the session ID has changed so it is no longer valid

This is what I have inside the For Each Element activity. If the element is found it works great and clicks, If it is not, it goes to refresh the browser then the click activity after that says the selector is no longer valid. The selector is the “CurrentElement” from the For Each UiElement activity

what you are passing selectors in click activity.
Use activate activity and try

so can you try to choose selector that are mroe reliable and use wildcards to make selectors more reliable.

  • After the page refreshes and the session ID changes, try to rely on more stable identifiers for the elements that don’t change between sessions. For example, if the element has any text, index, or unique properties that don’t depend on the session, you can use that as a dynamic selector.
  • If the session ID is part of an element’s selector, it can be difficult to keep it valid, but typically there are other attributes that remain the same (like the text, tag, or class names).

Yes I understand I need to make the selector dynamic but I don’t know how to do that because it is the selector being generated by the for each UiElement activity. How do I edit that selector? It doesn’t have the same option to edit in UiExplorer like a selector in a click activity would.

Hey @kasey.betts


if you open that Strict selector or window selector option which one you want to make dynamic just hoven in that <> option and open in Expression editor after this you can open it in Ui-Explorer Mode and make changes on it .

cheers