Click checbox depending on variable output


I have a column in excel with different numbers and I want to click in browser the checkbox which is next to the same number of excel.
For example, the first row is number 2, then I want to click the checbox which is next to number 2 (see screenshot attached).
Moreover, if the number I want to click doesn’t appear in the screen, I want to click in “Av.Página”.

I have the numbers from excel stored in a variable and I tried to use find element activity and then click activity using dynamic selectors. However, dynamic selectors doesn’t work.
The process I followed is: in find element activity select number 2 from brwoser and then add “aaname” attribute in UISelectors and change number 2 for the name of the variable.

Do you know which could be the error with dynamic selectors or another option to run this process?

Thank you very much for your help.


Screenshot from Browser

How does the selector for the checkbox look like? Could you post a screenshot of Ui Explorer with the checkbox selector?

Thank you!

That looks like the selector for the cell next to the checkbox. Have you tested to select the checkbox instead?

The selector for the checkbox looks like this. As in the checkbox doesn’t appear any number, I can’t change the number for the variable.
So, what I was trying to do is use anchor base activity where the anchor is the cell next to the checkbox and the activity is click the checkbox. That’s why the selector I attached before is for the cell next to the checkbox. Do you think that’s correct?

Yes, you are on the correct path using anchor base activity if there’s no way to identify the checkbox alone.

Is the id for the checkbox random or is connected to the number some how? Maybe “check_13_2” refers to the row with number 2? What is the id for the other checkboxes?

If it’s connected, maybe something like this would work:

<webctrl id='check_13_{{TarifaNumString}}' tag='INPUT' type='checkbox'/>

It’s connected but what changes is the number 13 which doesn’t have any relation with the variable.
The selector attached is the id for checkbox number 5.

Selector checbox

Ok, if anchor base doesn’t work for you, test with this: Use Get Attribute activity to get the “tableRow” attribute from the cell next to the checkbox. Save it to let’s say, strTableRow.

The selector should look like in the screenshot you posted but the remove the space in aaname. It should be aaname='{{TarifaNumString}}' without any space.


In the Click activity, set the following selector:

<webctrl tag='INPUT' type='checkbox' tableCol='1' tableRow='{{strTableRow}}' />

It’s OK to write the TarifaNumString variable as attribute? I didn’t know which attribute to put, but like I show you in the screenshot, it doesn’t work.

No, in the text field you should enter “tableRow”, because that is the attribute you want to access. Create a new variable called strTableRow to save the result.



The TarifaNumString should contain the value you get from Excel.

It appers error as well… I attached a screenshot from the error, so you can see how it looks.

I also tried to do this process without variables, meaning enter manually each number, and the robot doesn’t find the elements either. For example if I want to find number 2 in browser, the robot doesn’t find number 2 when actually there is number 2 in the screen. Maybe the problem is the browser?

From your screenshot, it seems like the aaname contains two spaces before 2 and a space after. The best is to select the cell with Ui Explorer and then replace only the 2 with {{TarifiaNumString}} and let all the surrounding spaces be. (Sorry for telling you to remove the space before. I didn’t know that **aaname ** had leading/trailing spaces.)


It works but only if the TarifaNumString variable is equal to 2. If the variable is another number it appears this error.

FlexGrid is also changing number. Test with this selector instead. It uses Regex to ignore any leading/trailing spaces and a wild card to ignore the FlexGrid number.

<webctrl aaname='\s*{{TarifaNumString}}\s*' isleaf='1' parentid='fila_FlexGrid_*' tag='TD' matching:aaname='regex' />


Now this is the error…

And the selector looks like this


The selector for the Click checkbox activity should be like this:

<webctrl tag='INPUT' type='checkbox' tableCol='1' tableRow='{{strTableRow}}' />

This one:

The selector for click activity looks like this:

Do I have to remove the “id” attribute?

Even though, the error appears in Get Attribute activity.

The Get Attribute is working fine now. Just update the selector for the Click activity. You can copy and paste it. There’s no need for id since we are using tableCol och tableRow to identify the checkbox.

If you want to include the id you will need to include a wild card since you don’t know what the numbers will be.

<webctrl id='check_*' tag='INPUT' type='checkbox' tableCol='1' tableRow='{{strTableRow}}' />