Handle CheckBox Radio Button in Selenium :

 

  • Using radio button we will be able to select only one option from the options available because multi radio buttons we can not select.
  • Using checkbox, we can select multiple options of different check boxes.

 

Radio Button HTML code:

 

Checkbox HTML code:

 

  • Using Click() method in Selenium we can perform the action on the Radio button and on Checkbox.

Example:

 

Example: Perform click operation or Handle Checkbox Radio button in Selenium:

 

Before performing on the Radio buttons or checkboxes need to verify:

  • Verify Radio button or Checkbox is displayed on the web page before perform any operation.
  • Verify Radio button or Checkbox is enabled on the web page before perform any operation.
  • Check the default selection of the Radio button or Checkbox before perform any operation.

 

Below Verify methods used in Radio Button & Checkbox: 

  1. isDisplayed()
  2. isEnabled()
  3. isSelected()

 

isDisplayed():

  • returns a Boolean value, if it returns true then said radio button ispresent on the web page or if returns False then radio button is not present on the web page.

 

isEnabled():

  • returns a Boolean value, if it returns true then said radio button isEnabled on the web page or if returns False then radio button is not present on the web page.

 

isSelected():

  • returns a Boolean value, if it returns true then said radio button isSelected on the web page or if returns False then radio button is not present on the web page.

 

Example of Verify Methods of Checkbox / Radio button: 

 

Select All Checkboxes: