Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selenium code to select radio button

Tags:

selenium

Am doing automation tesing using selenium, i need help in regarding how to select radio button.If possible help me with selenium java code.

like image 462
Gaju Avatar asked Apr 28 '11 12:04

Gaju


People also ask

How do you select radio button in Selenium?

Also, we can select Radio buttons by using the click() method. Selenium also offers validation methods like isSelected(), isEnabled() and isDisplayed(). We can use these methods before performing any operation to make sure radio buttons are in the correct state.


2 Answers

Assuming you have selenium set up its just:

selenium.click('radio button locator');

You may want to look at the selenium javadoc http://release.seleniumhq.org/selenium-remote-control/0.9.2/doc/java/com/thoughtworks/selenium/Selenium.html

like image 117
mark-cs Avatar answered Sep 20 '22 05:09

mark-cs


click > xpath=(//input[@type='checkbox'])[position()=1]
click > xpath=(//input[@type='checkbox'])[position()=2]
click > xpath=(//input[@type='checkbox'])[position()=3]
click > xpath=(//input[@type='checkbox'])[position()=4]

etc ... use this commands to select random and any radio button

like image 41
Mai Hanafy Avatar answered Sep 23 '22 05:09

Mai Hanafy