Working with CheckBoxes and Radio Buttons

In the previous post, we have seen the working with WebList in selenium. In this post, we will see the working with CheckBoxes and Radio Buttons.

In our demo application, we have 3 checkboxes with color names Red,Green and White etc. We will see operations like select check box, deselect check box, choose radio button etc.

Check boxes


 

Uncheck the checkbox ‘Green’:

We will find a unique property of check box to make a XPATH. If we inspect check box using Firebug, then we observe that ‘Value’ attribute is having unique value among all check boxes. We will consider this to create the XPATH.

Green checkbox

 

We will use the method click() to uncheck the checkbox.

Output: Check box ‘Green’ is unchecked.

 

Check the checkbox for color ‘Red’:

The click() method will be used to check the checkbox.

Output: Check box ‘Red’ will be checked.

 

Selecting the radio button:

We have 2 radio buttons in application for ‘Male’ and ‘Female’. ‘Female’ radio button is by default selected. We need to select the radio button for ‘Male’.

Select radio button in selenium

 

We need to use method ‘Click()’ for selecting the radio button.

Output: Radion button for male will be selected.

Radio button in selenium


Ask Question
Have any question or suggestion for us?Please feel free to post in Q&A Forum
Working with WebList in Selenium
Select random value in the Weblist
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. He is an automation engineer having more than 8 years of experience who loves troubleshooting in automation and finding innovative ways to solve the problems. His other leisurely activities includes playing harmonica, paintings, sketching portrait, watching movies and travelling etc.

You may also like...

Leave a Reply

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