Editing UIElement Selector dynamically

Hi, I am working through a UiElement list generated through Find All Children Activity. I am using the output to loop through each element and delete it from the list, however after one is deleted the automationid is now pointing to the wrong element. I need to edit only the automationid in the selector to account for this but cannot find a good method to manipulate the selector via UIElement Core Library.

Any help would be appreciated!

for each child you can output the full selector using

var = child.selector.tostring

that will allow you to then use newselector = string.replace(var, “New String”)

Thanks for the quick reply!

That works well for changing out the selector as a whole, but more specifically is there a way to edit individual element attributes (I saw an edit selector function but appeared to be deprecated)

ie. editing just the automationid but leaving the rest of the selector in tact.

Hi @aschape

Welcome to our UiPath Forum! :slight_smile:

It is absolutely possible to have selectors with variables (making a selector dynamic).
The easiest example would be to iterate the ID attribute of the selector within a loop. If you are on the 2019.4, you can actually insert a variable by right clicking on the value of the particular property. You will then see a handy menu that will help you out.

Otherwise, please search the Forum on “dynamic selectors”. There is plenty of examples out there :slight_smile: