Dynamic variable by passing through variable into IDX=''

I’m in dire need of some assistance. I’ve a double click activity, and I want the selector to be dynamic. Unfortunately, i have to pass through a variable into the idx=‘’. There is no other way to hit my target.

Using UI explorer, i retrieve the HTML code which is

I have a variable called “BLUE” which is an integer type (1,2,3,4,5,6,7,8,9 etc…) …

I converted it to another variable called “COUNT” which is a string type

Passing through the string type variable COUNT into my HTML code… I entered the below to Property - Target - Selector - click …

“”

When i run my bot, i am shown the below error

Message:‘aaname’ is an unexpected token. The expected token is ‘=’.

I attempted to edit my my code as
“”

Message:Syntax is not valid


Passing through the string type variable COUNT into my HTML code… I entered the below to Property - Target - Element - click …

“”

When i run my bot, i am shown the below error

Message:
Compiler error(s) encountered processing expression “”“”.
Value of type ‘String’ cannot be converted to ‘UiPath.Core.UiElement’.

Any assistance is appreciated.

Hi.

First I would suggest not using the idx attribute and check UiExplorer to see if there is any other attributes shown on the right side of the window that can be used instead.

However, if you do need to use the idx attribute, you can edit the selector “as a string”. To do so, click in the Property textbox for Selector, and you will notice that the selector will have quotations surrounding it. Therefore, edit the selector as a string while there are quotations around it.

If you edit it in the Selector Editor, this will NOT work. So make sure you are in the Expression Editor or in the Property textbox. There are also tricks where if you delete a character, then click the three dots, it will bring up the Expression Editor rather than Selector Editor (make sure you place back the removed character.

After editing the selector as a string using string concatenation, it should look like this:
"< idx='"+count.ToString+"' />"

Hope that helps.

Regards.

1 Like

Unfortunately, i have to use idx and your suggestion. Thank you so much

Hi, Iam facing a similar issue, could you please elaborate on

Where can the property textbox for selector be found? or the expression editor in Property textbox. Iam trying to use idx= ‘“+count.ToString+”’, for a textbox in a webpage, whose number changes dynamically based on a condition. The idx value will really help in selecting correct textbox.

Hi @sawaseem,
To access the expression editor, click in the Selector property box.
image

The selector will be surrounded by quotes so you can edit it to concatenate variables. Or, if you make it an invalid selector by deleting a character, you can click the 3 dots to edit, and the expression editor will show instead of the selector editor, but make sure you put back the character you deleted that made it invalid.

Regards.

1 Like

Thanks so much for your help.
That trick of deleting a character, e.g.;“<” to open the exp editor rather than selector editor, really helped!:+1: