How to work with radio
button in web driver?
We can
select the value from the drop down by using 3 methods.
selectByVisibleText -
select by the text displayed in drop down
selectByIndex - select by index of option in drop down
selectByValue - select by value of option in drop down
<select
id="44"> <option value="1">xyz</option>
<option
value="2">abc</option>
<option value="3">pqr</option>
</select>
WebElement e =
driver.findElement(By.id("44"));
Select
selectElement=new Select(e);
// both of the below
statements will select first option in the weblist
selectElement.selectByVisibleText("xyz");
selectElement.selectByValue("1");
seams to be question is different and answer is different.
ReplyDeletecorrect...Answer is for selecting values from dropdown with normal type of dropdown. Here, answer for selecting values from DD of anchor tag is also missing.
Deletewhat if multiple radio buttons are available on a webpage ?
ReplyDeleteYou will use contains to locate them
DeleteHi Ruchi,
ReplyDeleteCan you copy the sample code for check box, raiobutton, multiple select in drop downs code
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Deleteselect a radio button with Selenium
WebElement e = driver.findElement(By.id("ID of the radio button"));
ReplyDeletee.click;
// both of the below statements will select first option in the weblist
selectElement.selectByVisibleText("xyz");
selectElement.selectByValue("1");
Great article..It was really informative and useful. selenium training in chennai
ReplyDeleteselenium training in velachery
best selenium training in chennai