How To Handle Radio Buttons Dynamically In Selenium

Опубликовано: 27 Апрель 2026
на канале: Teach Yourself Test Automation
1,201
7

How To Handle Radio Buttons Dynamically In Selenium | http://teachyourselftestautomation.com
Selenium Certification Training: http://bitly.com/2PA8HCA

Hello and welcome to Day 20 - How To Handle Radio Buttons Dynamically In Selenium

Our practice website same as that of day 19
https://www.dyn-web.com/tutorials/for...

Visually we can see from the website we have 3 radio buttons
Our requirement is to return the count of number of radio buttons in the console

To start we have to look for an attribute common to all our radio buttons on screen

Here the common attribute with same value is attribute type and value radio

We will use our attribute above an write an xpath to retrun all three count of radio button with method .size

And if we wrap our code around to java print line command then we will print output of count of radio button into our console

We head over to eclipse and name our new test case radiodynamic copy over the three common line of code for every test case you would write

Then we go ahead to write line of code to count number of radio buttons on webpage

Once done and you run test case you should see output of 3 in the console informing you there are indeed 3 radio buttons on screen

After finding the count of radio buttons we could use this and select a button at a time using index

With index the radio buttons small=0, medium=1 and large=2

So when we write our code to click on small radion button we make use of 0 in the code and when it's medium to select make use of 1 and large will be 2

When we use the Java for loop we can select each radio button one after the other, checkout video for more info on this

Please see video for live examples on the above    • How To Handle Radio Buttons Dynamically In...  

Don't forget to subscribe if you found this video helpful, support the channel and SUBSCRIBE

Many Thanks

Kevin Owasu Itoe

How To Handle Radio Buttons Dynamically In Selenium | http://teachyourselftestautomation.com
--------------------------------------------------------------------------------------------------------
Follow me @
Facebook:   / kevin.itoe.50  
Google+: https://plus.google.com/u/0/103559195...
Pinterest: https://www.pinterest.co.uk/owasuik/
My Blog: http://teachyourselftestautomation.com/
My YouTube Channel:    / @teachyourselftestautomatio1271  
--------------------------------------------------------------------------------------------------------
My Videos:
   • Install And Configure Java | Selenium Webd...  
   • Eclipse Installation | eclipse software | ...  
   • Java Project Template | Java Projects | My...  
   • Download And Configure Selenium | Selenium...  
   • Basic Selenium Test Script To Invoke Web B...  
   • Selenium Tutorial | WebDriver Browser And ...  
   • Selenium Webdriver Locators | Locators In ...  
   • Find Elements On Web Page With Link Text X...  
   • How To Validate Xpath And CSS Using Browse...  
   • How To Write Customized Xpath In Selenium ...  
   • CSS Selector | How To Write Custom CSS Sel...  
   • Preceding-Sibling Xpath | How To Identify ...  
   • How To Handle Static Dropdown Selenium Web...  
   • What Is The Difference Between Absolute XP...  
   • Video  
   • How To Automate Selecting A Checkbox In Se...  
   • How To Automate Radio Button In Selenium W...  
   • How To Handle Radio Buttons Dynamically In...  
-------------------------------------------------------------------------------------------------------
What Wikipedia says about selenium: https://en.wikipedia.org/wiki/Seleniu...)
What Wikipedia says about test automation: https://en.wikipedia.org/wiki/Test_au...