Working with Radio Buttons

Learn how to find and interact with radio buttons using Selenium.

Select a radio button by ID

Most of the time, we can use the ID of the radio button to click it.

driver.findElement(By.id("radio_female")).click();

Select a radio button by name

Another less efficient way of selecting a radio button is to use its name:

driver.findElement(By.xpath("//input[@name='gender' and
...

Get hands-on with 1400+ tech skills courses.