Can I make a dynamic selector using an argument which is assigned a variable?

Hi,

I need my automation to select a Ui element based on an anchor which could change. Thus, I have been trying to implement dynamic selectors by changing the “aaname” of the anchor element to a wildcard / argument which would be assigned the value I want.

Although this works if I assign the argument a default value, it will not work if I assign this argument to a variable that contains the value I want. When I try this, I get this pop up (see attached picture).

UiPath Dynamic Selector Troubleshooting

Ultimately, I need the latter option to work because this workflow will be invoked and the value of the “aaname” will be passed from variables in the main workflow to the arguments in this invoked workflow.

So to repeat my question: is it possible to assign a variable to an argument (during an invoked workflow) and then use that argument (without a string default value) as a wildcard for a dynamic selector?

Hey @Ben_Wong1

I guess you are trying it in compile time as of now right ?

Kindly run the program, it should work provided the aaname value you pass through variable is valid.

Thanks
#nK

Hey @Nithinkrishna

When I have tried running the program, it will not work and gives me this Runtime execution error which is stating it cannot find the UI element.

Thanks!

As per my understanding you should be able to do that, if you have properly configured the argument.

Here you are getting the error during execution, so have you checked the value of argument in debug mode or you can print it in console.

@Rahul_Unnikrishnan

I have set up a message box which confirms that the value is being assigned to the argument, but it still cannot find the ui element. I have also tried putting a delay in but that didn’t solve it.

Thanks!

Make sure you don’t have a variable with the same name as the argument. Also, that first screenshot you posted is because you’re trying to use a variable while designating the selector. I find it’s easier to just let it get the selector with the specific text, then copy/paste the selector into notepad and edit it manually to replace with variables. Then paste back into the activity’s property.

Hey @Ben_Wong1

Please show us the actual selector before making it dynamic as well after image ?

Thanks
#nK

@postwick

Thanks,

  • I changed it so that variables and arguments have different names

  • if you were using a variable for the selector, which selectors would you choose ( fuzzy, strict, image)?

You can’t use variables with image.

I generally use strict selectors as long as they work, whether I’m using variables or not. I prefer to have my selectors exact, and don’t really like how fuzzy will find things that are close. Close is not right, in my brain.

Hey @Nithinkrishna

Here are the pictures of the selector before and after making it dynamic

Before Dynamic

P.S. I have also tried to check / uncheck the image selector but it has not seemed to make a difference.

Thanks!

After dynamic

Take the class out of your selector. That’s an unreliable attribute. Also remove type since it’s blank. DIV and aaname should be enough to uniquely identify the UI element.

It may just be my imagination, but is there an extra space before and after (x) Category?

Hey @Ben_Wong1

Kindly uncheck Fuzzy and check the Selector option as you are looking for an exact match.

As an alternative you can even make the Fuzzy match value to 100%

Thanks
#nK