TestProject Forum

Click on a checkbox based on its label

Is there an action / add-on that help us click on a checkbox based on its label? See the below example:


I want to click / check the correspondent checkbox that I’m passing in the test parameter ‘Learning Object Type’. For, instance if ‘Learning Object Type’ parameter contains ‘Event’, the Event checkbox must be selected. How can I achieve this?

Thanks in advance.
Best regards,
Sandro Pinto

Hello @sandro.pinto
You can use a dynamic locator with a parameter, look at the example I did on this site:
https://www.seleniumeasy.com/test/basic-checkbox-demo.html
I first created a parameter
image
The default value will be Option 1
My next step is to create a click action with a dynamic locator
image
I use the parameter instead of the label value
image
Now the click will be on the first option because it is the default value


But if the value changes:
image
The position of the click will also change: