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.
Main.xaml (12.0 KB)
Hope it helps!!