Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

Select a Radio Button Using Selenium in Python



We can select/click the radio button with Selenium. In an html document, each radio button has an attribute type set to a value as radio. In order to select a radio button, we shall first identify it and then apply the click() method to it.

Example

Code Implementation.

from selenium import webdriver
driver = webdriver.Chrome (executable_path="C:\chromedriver.exe")
# maximize with maximize_window()
driver.maximize_window()
driver.get("https://www.tutorialspoint.com/selenium/selenium_automation_practice.htm")
# identify element and click()
l=driver.find_element_by_xpath("//input[@value='2']")
l.click()
driver.close()

Output

Updated on: 2020-08-28T13:00:04+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements