UIPATH: Add dynamic variable as a counter in the idx selector of a click activity.

Hello guys,

I’m actually working on a UIPATH Project, I need your help for one Sequence.

The part of my project where I’m struggling is about Click on one logo on a web page, then Click on the same one under, then the same one under and so on even logo exists.
I would like to modify the selector of the click activity, to remove the static idx by a dynamic idx as a variable to automate the process.

I have tried to initialize by Index=1
Then to remove in the Click selector : idx=‘1’ by idx=’"+Index.ToString+"’ but the selector is not working…

Could you help me about how to pass the variable and its syntax. :slight_smile:

1 Like


Your syntax is correct only.

Could you please take screenshot of Your original and modified selector and paste it here. Will check and let you know.

What error you are getting?

Selector%20IDX Error%20Message

Thanks for your help ! :slight_smile:

Hey @AmauryCarlier,

You can use Find Children activity to get the no of icons.It will give you an Ienumerable of Uielement then you can loop thorugh it and pass the element inside the click activity.

Many thanks for your answer @amarasto ,

My problem is about to click to the second logo Under because the idx of the second one is : idx=‘2’ and not Idx=‘1’. So how Can I manage it ?

if you will loop through the uielement array then you dont have to deal with the idx attribute that will automatically handled by the looping itself.

It still doesn’t work, with the Find Children activity and the for Each in Children (Variable) the Bot still click on the First Logo but not the next one. I share you the XAML file if you agree to have a look on it.
Thanks :slight_smile:Create or Update New Container 4.0.xaml (39.2 KB)

personally I would use a string variable to build the selector and then provide this variable in Click activity.

strSelector = “<html url=‘https://…span’ idx=’” + cstr(index) + “’ isleaf=‘1’…/>”


1 Like

Hi @AmauryCarlier,

Welcome to the Community! You should be able to pass the Index value as a parameter to the selector. From the screenshot above it looks like the quotes before and after are not set correctly.

Instead of &quot;+Index.ToString+&quot; it should be "+Index.ToString+"

You need to use the Expression Editor to ensure it translates correctly.


Have updated the selector in your workflow. Give it and try and let us know how it goes.

Create or Update New Container 4.0.xaml (39.2 KB)

Hey @AmauryCarlier,

Please find the screen shot below.There is little correction in properties pane.

Can you try it and let me know if it works?

1 Like

Thank you very much @goodoldme and @amarasto, both solutions are working ! :slight_smile: