How to use a variable in: <webctrl aaname=VARIABLE />

could someone please help me sort out this issue?

To be simple,
When you click an element and create your selector, it places the selector as an expression for you automatically. You then can edit it by clicking inside the Selector Property of your Click activity (don’t click the edit button). You will notice that the selector is as a string with quotes around it. You can then edit that string to replace parts of it with variables.

For example,
“< title=ABC >”
can be replaced with “< title=”+variable+" >"

Remember, this is in the Selector Property text box; not in the editor.
You can also use the UIExplorer then copy your selectors over, then again, click inside the text box to edit the string.

After you have edited the string to include variables, you will also notice that when you click the edit button it pops up with an expression editor instead of selector editor, so that might help you.

… I probably just confused you but hope this helps, lol.

10 Likes

Thanks Clayton for the detailed explanation, will try and share the results

This helped me too

hi @Hibb to use expression editor should we go with Uipath variable assignment , or directly write in to Expression field.
Do we have to replace entire selector or only the attribute part, I am highlighting the value I want to pass through variable , please suggest

Selector Editor

image

Vs Expression Editor

Hey You are passing your selector in Element property.
You should pass it into selector property.

Regards…!!
Aksh

Hello @aksh1yadav thanks for response
same has worked for me in few solutions, just wanted to learn about Expression Editor in detail which is mentioned in this post , share the link if any example is given

:slight_smile:

Thanks
Hitesh

@hkjobs1988 @aksh1yadav
hey how did you solved it? I am trying to pass a variable into the expression editor. I assigned the selector attribuite to a variable with datatype string. Then I tried calling this variable into Element property of Click. But when I call I am getting error that string cannot be converted to Uielement.

This is my Assign

image

this is the property side of Click activity
image

Thanx in advance

hello , @amithvs check below part in attached solution

image

Main.xaml (40.9 KB)

2 Likes

Hey @amithvs

you are passing that in Element property so it Is showing that error. you have to pass that selector string in selector property.

Regards…!!
Aksh

1 Like

@aksh1yadav @hkjobs1988 thanx for the quick reply. But click is not working when variable is called within attribuite. There is no validation errors, but getting error like below

cannot find ui element

I am also having a similar issue… I have to click a dropdown menu which contains a list and I have to iterate the Click activity through the drop down menu. But when I call variable inside the selector property, the click is not working…

This is the error I am getting :

: Cannot find the UI element corresponding to this selector: <webctrl aaname=‘System.String[]’ parentid=‘searchForm’ tag=‘A’ />

check the generated selector with your variable value. use writeline after that. check with the value and space.

check you are passing an array of string just pass a name of that element which you want to click.

Hey thanks for quick response…
But I didnt get that properly …

Suppose I am having array of string var1= {“a”,“b”,“c”}… and my dropdown consists of
a
b
c
I edited the selector property and assigned that value to another variable.

ie; var2= <webctrl aaname=‘“+var1+”’ parentid=‘searchForm’ tag=‘A’"/>

I have to first click a, then b and finally c.
Inside click selector property, I tried calling the variable var2

No validation errors…But still no luck with click activity !!!

Hello @UnicornStark
your code should be like this:
For each item in var1
Click acitivity-Selector: “<webctrl aaname=’” + item.tostring + “’ parentid=‘searchForm’ tag=‘A’”/>"
if needed give delay

1 Like

Hi I am a real newbie but trying-- I want variable for idx=1 I want idx=intcounter ( intcounter is a variable type int)
I understand I have to use expression editor instead of selector editor.
You state manually drag object from list on left do u mean activity from activity list in my case it is “click” clicking on properties brings upexpression editor as u state.
Next u state "What I now do is use “record” to stage my process, then delete the object on which I want to use the Expression Editor and then manually added it back. " This is not clear to could u pls explain!!
Thanx

Hi @amithvs ,
when we add a variable in selector using the Selector editor as shown in the picture
selector%20editor%20uipath
will be changed to


So

4 Likes

Hi All,

I have similar problem. I have read through all the responses above and am sure I am missing on something.
I am trying to select a date in the google calendar and instead of taking that exact date I am using a variable instead. For now, I am using that variable with a fixed value.

I am not able to use that variable in the selector

Below is the screenshot of my selector

Can someone suggest whats the problem here?

Hi @anshulagarwal,

Copy the below selector and paste in the selector properties

"<html app='Chrome.exe' title='Google Calendar-*' /><webctrl aaname='"+num.ToString()+"' parentid='drawerMiniMonthNavigator' tag='DIV' />"

Refer the Previous post

Regards,
Arivu

1 Like