How to click each checkbox on a for each

Hi there,

I am trying to read a table and inside a for each name on that table to select a checkbox that has the name at a web page’s form and it does not click at all can someone help?

Hi @siteltower

If you are trying to extract data - use data extraction wizard / data scraping.

Check boxes can be checked/unchecked with check/uncheck activity.

image

Kind Regards

Hi @Che I am extracting data already and saving the names but for each name I need to click on its checkbox and its not clicking

You have to do a dynamic selector for the Check/Uncheck activity if you use data scraping. This is not the ideal way to do it.

A better way to do it is the Find Children activity, which gives you an array of the actual objects on the page. Then you just loop through and pass the object itself to the Check/Uncheck activity.

1 Like

HI @siteltower

Welcome to Community!

You can try this way

  • Use DataScrapping and store the values in the datatable.
  • Assign Activity integer CheckBoxCounter = 1
  • And loop through the datatable with for each row in datatable
    • Use click or check activity and in the selector of that activity you need to pass the variable “CheckBoxCounter” in the idx or table row properties
    • At the end of the for each row in datatable assign CheckBoxCounter=CheckBoxCounter+1

By doing this it will click on next next boxes while looping through all the rows

Regards
Sudharsan

Thank you
I’m not familiar with this Assign Activity integer CheckBoxCounter how would that work?

Actually that is the normal assign activity

Variable name will be CheckBoxCounter and the datatype is integer that is what i meant there

Regards
Sudharsan

1 Like

He just means use an Assign activity to set the counter variable to 1, then increment it each time.

Again, though, it’s much simpler to just use Find Children to get an array of the objects.

Here are the keys to making this work.

In the Find Children activity, you indicate the container that holds the checkboxes you want to check. This is the selector. In the filter you then designate that you want only the objects with type=‘input’ (this depends on the actual web page you are using, you use UI Explorer to click a checkbox and see its selector to find an appropriate filter). Also, make sure to set the scope to FIND_DESCENDANTS. Lastly, the Children property takes a variable of type system.collections.generic.ienumerable(uipath.core.uielement) - in other words, an array of uielement objects. Easy way to create this variable is to click into the property and press CTRL+K then type the name of your variable and press enter. This will automatically create a variable of the correct type (array of uielements).

image

Then in your For Each, you reference the same array you put into the Children property above. Make sure to change TypeArgument to uipath.core.uielement:

image

Then in the Check/Uncheck activity, you pass the loop’s variable which contains the uipath.core.uielement object you want to click:

image

1 Like

Hi

I have this check boxes and for each one I need to click and perform some actions…

I’ve tried this solution but if gives me an error there

I also share the process here so if you can give me further assistance or anyone in the community please
checkboxInterate.xaml (11.8 KB)

You don’t pass the array (checkboxes) to the Check/Uncheck. You pass the array to the For Each. The variable (checkbox) you pass to the Check/Uncheck comes from the For Each.

image

In what you posted, you have “checkbox” as the array. “checkbox” should just be uipath.core.uielement - a variable that holds a single object not an array.

Also, get rid of the selectors in your Check/Uncheck. ONLY fill in the Input Element box.

1 Like

It works perfectly now
Thank youuuuu :smiley:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.