Handling CheckBoxes in selenium

Events for a checkbox can be check or uncheck, there can be one or more checkboxes (group wise) on a webpage.

Checkboxes can be identifies in html DOM with tag as ‘input’ and type as ‘checkbox’ as shown in below screenshot.

let’s see some of the implementations on checkboxes in selenium

capture all the checkboxes in a webpage:

But let’s say, we want to capture a particular group of checkboxes (based on name attribute), in the above screenshot, as u can see, we have a group of checkboxes with all as atribute name ‘language’

Let’s see the code for the checkbox operations:


e.getAttribute(“value”) returns the value of a particular checkbox.
e.getAttribute(“checked”) returns null if a particular checkbox is not checked else return true.

Content posted is based on learning or working experience,
Share the post with others if find useful,
Any queries?, leave comments or discuss on our facebook:qavalidation.com, Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *