How to select checkboxes and radio buttons in Selenium webdriver

Selenium is an open-source web-based automation tool and testing framework. In this answer, we will learn how to select checkboxes and radio buttons present in the DOM using the Selenium web driver in Python.

Syntax

radio_button_element.click()
checkbox_button_element.click()

To select the radio button or checkbox, we just need to call the click() method on that element.

The click() method doesn't take any parameters and returns none. It just performs an action.

Let us take a look at an example of this.

Example

from selenium import webdriver
#specify where your chrome driver present in your pc
PATH=r"C:\Users\gutkrish\Documents\chromedriver\chromedriver.exe"
#get instance of web driver
driver = webdriver.Chrome(PATH)
#provide website url here
driver.get("https://omayo.blogspot.com/")
#locate radio button and click it
driver.find_element("id","radio2").click()
#locate checkbox and click it
driver.find_element("id","checkbox2").click()

Explanation

  • Line 1: We import the webdriver from the selenium package.

  • Line 5: We will be creating and passing a variable PATH with value as a path pointing to the web browser driver. For Chrome, it is the chromedriver.exe driver in the Windows environment.

  • Line 8: We get the instance of the webdriver.

  • Line 11: We provide the URL to the driver.get() method to open it in a browser.

  • Line 14: We find the radio button element using its id radio2 and call the click() method to select it.

  • Line 17: We find the checkbox element using its id checkbox2 and call the click() method to select it.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved