How to select a check box based on check box label

I was trying to select check box based on condition as below:

Test Site: http://demo.guru99.com/test/radio.html

To automate this web page, my requirement is

  1. Display Input Dialog box where user will enter check box label i.e. ‘Checkbox1’, ‘Checkbox2’, or ‘Checkbox3’
  2. based on provided user input, i wanted to select that particular check box; if it’s not already selected. If it’s already selected then don’t perform click operation on that check box.

I tried it using anchor base; however unable to get proper selector so that i get any property of checkbox label and provide the label name as variable into selector.

Could you please help me into it?

You can include a value in the selector.
I’m using chrome, so you may need to adjust the first line if you aren’t.
Value:
image
The reason you can’t select by using the Checkbox1 label is because it isn’t really related to the checkbox at all and it doesn’t have a lot of distinguishing features.
Other than this you could try using one of the click on text activities, but they tend to be less reliable.
Play around with UI Explorer to get a feel for how UiPath sees the webpage.
You may also want to have a look at the Check Activity.

1 Like

Hi @gopal_1981

As @jfarnden suggested use check activty but before that use an element exists with aastate and an if condition

for eg StrOutput.ToString.Contains(“focussable active”)

and then use check activity

Thanks
Ashwin S

Hi,

The following might help you. (You might need to adjust offset of Find Relative Element.)

Sample20200117-2.zip (10.8 KB)

Regards,

1 Like

Thanks for workflow.
I am getting ‘Activity timeout exceeded’ error for fist FindElement activity where you have given selector:
“”

I could not find ‘Value’ attribute in UI Explore for any of the element on that web page. So Selector cannot be validate if i use value=‘Checkbox1’.

The value you specify in the selector has to be exactly the same as what’s on the website.
The selector i posted was based on this bit of the source code on your example website:
image
If you use value=checkbox1 in the seletor it will match, but value=Checkbox1 will fail because it’s slightly different.

1 Like

Thanks for reply. I got it now. You get ‘Value’ attribute when you inspect the element in chrome.
I was under impression that we get all possible attribute in UiPath UI Explore window. but in this case, ‘value’ attribute is not there ui explore.