- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 find a radio button element by value using Selenium?
We can find a radio button element by value with Selenium webdriver. A radio button in an html document has a tagname input and it has a type attribute set to radio. We can select a radio button by using the click() method after identifying it.
Let us see the html code of a radio button. To identify it with a value attribute we have to use the xpath or css locator.
Example
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class RadioButnVal{ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver","C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); WebDriver driver = new ChromeDriver(); String url="https://www.tutorialspoint.com/selenium/selenium_automation_practice.htm"; driver.get(url); driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); // identify element with value WebElement l=driver.findElement(By.cssSelector("input[value='3']")); //select radio button with click() l.click(); driver.quit(); } }
Output
- Related Articles
- Using Selenium in Python to click/select a radio button.
- How to create a Radio Button using JavaFX?
- How to select a radio button in a page in Selenium with python?
- How to uncheck a radio button using JavaScript/jQuery?
- How can I send radio button value in PHP using JavaScript?
- How to select a radio button by default in JavaScript?
- How to set “value” to input web element using selenium?
- How to change the color of the radio button using CSS?
- How to use Radio button in Android?
- How to set OnclickListener on a radio button in android?
- How to use Radio Button in Android Kotlin?
- How to find an element using the “XPath” in Selenium?
- Find the Sum of Radio button values jQuery?
- Bootstrap Form Radio Button
- How to get the total number of radio buttons on a page using Selenium?

Advertisements