Issue on UiPath RPA Academy Lesson 6 - Selectors Part 3 - Dynamic Selectors

Hi,

So in this activity the task is to be able to take input, (stored in variable name “digit” of GenericType) and then based off that input the bot will highlight the specified number on the calculator.

Following the video’s instruction I get this code when I use Edit Selector for the Highlight Activity.

<wnd app='applicationframehost.exe' appid='Microsoft.WindowsCalculator_8wekyb3d8bbwe!App' 
title='Calculator' />
<uia automationid='NumberPad' cls='LandmarkTarget' />
<uia automationid='num0Button' omit:cls='Button' omit:name='Zero' />

What the video does is on the fourth line gets replaced such as

<uia automationid='num"+digit+"Button' omit:cls='Button' omit:name='Zero' />'

However this code does not work for me, when I modify the code as per the video instructions and press OK, my code just changes to this automatically and what actually happens is only 0 gets highlighted regardless of my input.

<wnd app='applicationframehost.exe' appid='Microsoft.WindowsCalculator_8wekyb3d8bbwe!App'     
 title='Calculator' />
<uia automationid='NumberPad' cls='LandmarkTarget' />
<uia automationid='num0Button' cls='Button' name='Zero' />

How can I get my project to accept my variable in the Edit Selector and successfully complete the task?

Also I don’t know if the link is accessible but here is the link to the video I am talking about. https://academy.uipath.com/learn/course/511/play/5224/lesson-6-selectors-part-3-dynamic-selectors

Thanks.

Selector_Solution.zip (1.8 KB)

to get the selector use UiExplorer and make your selector in one line and add quotation at both the ends.
for eg:
if this was your selector
.uia automationid=‘NumberPad’ cls=‘LandmarkTarget’ />
<uia automationid=‘num0Button’ cls=‘Button’ name=‘Zero’ /

make it as
“”

then Paste this into the Selector Box under Target section in Properties section for Desired Activity here Click Activity.
I Have attache a note and the work flow for the refrence.

Hope This would help

Regards,
Ashley Nihal Dcunha

1 Like

Adding to what @ashley11 already mentioned, if it’s a generic variable then better to add

“YourVariable.ToString”

Cheers…!

1 Like

Hey I just wanted to update what happened. So previously I was trying to edit the selector in this window image

But that screen does not recognize I am trying to concatenate digit into the selector. So I needed to go into the actual Properties panel itself and modify the selector string there.

image

EDIT: For anyone viewing this later in the second screenshot I should of put digit.ToString my bad.

I also noticed after I have done this “+ +” concatenation, when I now try to open the Selector window I get:

My issue is solved now, but is there anyway to get to the last screenshot I showed without typing “+ something +” into where I showed in the 2nd screenshot?

Thanks!

@rmckinnon

If we want to make selector dynamic we have to pass either variable into selector or have to use wild cards like * or ?. And we don’t have any other option to do this.

And also if we want to use dynamic selector then no need to indicate on the screen and just go to selector option in properties and copy paste the selector and make sure it should be enclosed in double quotes.

1 Like

Yeah that’s a good point. Thanks for the input.

1 Like

When I did this lesson, it instructed me to remove the name attribute and cls attribute of the automationid attribute along with the NumberPad container and the cls attribute from the application window. I attempted to add the “+digit.ToString+” with this method and was continuing to get errors. It wasn’t until I reselected and only removed the name and cls attributes of the automationid, leaving the container and cls attributes in the application window, did it finally work. Final selector code shown below:
image

For example, below 2 lines are doing the same thing but second one is more readable