Click checkboxes one after the other

Hello together,

I want to click checkboxes one after the other. It is important to do so:
a) Clicking the first checkbox - Execute a sequence.
b) Clicking on the second checkbox - executing a sequence.
etc.
The number of check boxes is variable. It can be that there is no checkbox at all or 20?

Attached is a picture:
grafik

Important: The top checkbox must not be clicked!

Hi!

You can try with check activity!

Regards,
NaNi

Hey @paul2! Interesting question! First I’ll explain the approach in a macro way.

→ Initially we are going to go through the elements of this page, we are going to identify which are checkboxes and we are going to mark them.

For this solution I am using a basic example website. (Bootstrap Checkbox - examples & tutorial)
With these two example checkboxes.

Let’s go to the solution!

  • Step 1: Let’s find the “Find Children” activity to return the child selectors of a certain element.

Attention point 1: In this activity I selected the selector that seemed to correspond to a direct parent element of the checkbox elements. In this case, you can increase the selector more and more, even if it is the entire page selector, to ensure you capture the children of interest.

Attention point 2: In my case I had to use the DESCENDANTS scope. Check what works best for you.

The Output of this activity is an IEnumerable of UiElement. Which I stored in the variable child.

→ Step 2: We are going to iterate through the selectors extracted in the previous activity looking for the checkboxes. Notice that in the for each properties, we are going to use the argument type as UiPath.Core.UIElement

→ Step 3: For each selector we will take the attribute “type” and store it in the variable “res” of type String.

“But why, Gabriel??”
Ans: By default, checkboxes in html are INPUT tags with the attribute “type=checkbox”. This is how we are going to identify which selector is from a checkbox.

Attention Point: We will need to pass the selector to the “Get Attribute” activity as follows, look at the image:

→ Step 4: Check if the “type” attribute is “checkbox”, if it is, we will use the “Check” activity to check.

Attention Point 1: This part of the flow is inside the for each.

Attention Point 1: As with the “Get Attribute” activity Let’s pass the selector of the “Check” activity as follows.

From here you can add your conditional to not check the first one, using a variable for counting, if it’s the first checkbox found, don’t check it. Otherwise, check.

The .xaml.
Main.xaml (12.0 KB)

Hope it helps!!

2 Likes

Hey @gabrielribas4,

Step 1: is clear
Step 2: also clear
Step 3: Get Attributes: I am not sure where to enter what here in this activity. Also, do I need to take a screenshot/preview?
I tried your settings: “type” and selected the selector. However, I get an error message: " The destination is invalid because no destination method is enabled. I then selected the target method “selector”. The error message is gone. Do I still need a screenshot?

Step 4: In my UiPath version there is no activity called Check, only Check/Uncheck. But this should work analogously. Do I take a screenshot of the first/top checkbox I want to activate?
How does the bot recognize that it has to activate the next checkbox on the next run of the For each loop? I am unsure how to change the properties from the check/uncheck activity.

Thanks for your detailed solution

Paul

Hey @gabrielribas4,

grafik

I have not yet managed to click one line or one checkbox after the other

Can you possibly give me another tip?

Hi @paul2

Try this way

  • Use datascrapping and get all the rows in the datatable.
  • Assign Counter(int)=2
  • For each row in datatable
    • Use click activity and indicate on the checkbox and open the selector in Uiexplorer and enable the idx (Change numbers manually and highlight the value it will switch to next check boxes ,After checking pass the variable Counter(int) in idx) and disable the aaname or text or something which contains the date text with it
    • Do your process and at last increment the counter

Regards
Gokul

Hey @paul2!! Sorry for the late answer!

Get Attributes: I am not sure where to enter what here in this activity. Also, do I need to take a screenshot/preview? I tried your settings: “type” and selected the selector. However, I get an error message: " The destination is invalid because no destination method is enabled. I then selected the target method “selector”. The error message is gone. Do I still need a screenshot?

Answ:You don’t necessarily need a screenshot! UiPath inserts in its activities a better detail and visualization in case of maintenance and assistance in code. What really matters is the chosen one, as you yourself can be! So you can mentally follow these settings that you have placed calmly.

In my UiPath version there is no activity called Check, only Check/Uncheck. But this should work analogously. Do I take a screenshot of the first/top checkbox I want to activate?
How does the bot recognize that it has to activate the next checkbox on the next run of the For each loop? I am unsure how to change the properties from the check/uncheck activity.

Answ: As I commented above, no Screenshot is needed in activities, you just need to pass the selector in “Target>Selector”. The code will go through selector by selector and check through “get attribute” if the value “type” is “checkbox”. Whenever it finds a “checkbox” selector it will check.

If you still have questions after trying this approach, we can build this flow together! Let me know!

Hey @gabrielribas4,

I’m running into another problem here again and again. It would be mega cool if we could look at it together.

Many greetings

Paul