
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to select a radio button in a page in Selenium with python?
We can select a radio in a page in Selenium with the help of click() method. First of all we need to uniquely identify the checkbox with the help of any of the locators like css, xpath, id, class and so on.
Next we have to use findElement() method to locate the element and finally perform the clicking action. The exception will be thrown if there is no matching element found on the page.
Syntax
driver.find_element_by_xpath("//input[@name='radio-button']")
Example
Code Implementation for radio button selection.
from selenium import webdriver #browser exposes an executable file #Through Selenium test we will invoke the executable file which will then #invoke actual browser driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") # to maximize the browser window driver.maximize_window() #get method to launch the URL driver.get("https://www.tutorialspoint.com/selenium/selenium_automation_practice.htm") #to refresh the browser driver.refresh() # identifying the radio button with xpath then click driver.find_element_by_xpath("//input[@value='Female']").click() #to close the browser driver.close()
- Related Questions & Answers
- Using Selenium in Python to click/select a radio button.
- How to select a radio button by default in JavaScript?
- How to count the total number of radio buttons in a page in Selenium with python?
- How to find a radio button element by value using Selenium?
- How to check a checkbox in a page in Selenium with python?
- Save a Web Page with Python Selenium
- How to create a Radio Button using JavaFX?
- How to get the total number of radio buttons on a page using Selenium?
- How to click on a button with Javascript executor in Selenium with python?
- Click a href button with Selenium and Python?
- How to set OnclickListener on a radio button in android?
- How to get the complete screenshot of a page in Selenium with python?
- How to use Radio button in Android?
- How to count the number of checkboxes in a page in Selenium with python?
- What to press ctrl +f on a page in Selenium with python?
Advertisements