Joe
Joe

Reputation: 2633

How to find a radio button element by value using Selenium?

Until now I just did like:

val radioButton4: WebElement = driver.findElement(By.id("FieldsubCode2"))

radioButton4.click

but now I want to find element by value, this value:

enter image description here

So I want to go:

val radioButton4: WebElement = driver.findElement(By.value("3.2"))


radioButton4.click

How can I do that?

Upvotes: 16

Views: 44597

Answers (4)

rvictordelta
rvictordelta

Reputation: 668

In python, it's

driver.find_element_by_xpath("//input[@name='buttonName' and @value='3.2']")

Upvotes: 4

Shoby
Shoby

Reputation: 103

driver.FindElement(By.cssSelector(input[type='radio'][value='3.2']));

Upvotes: 5

Bharat DEVre
Bharat DEVre

Reputation: 559

If you want to find only by value then use,

driver.findElement(By.xpath("//input[@value='3.2']"));

Upvotes: 14

Termininja
Termininja

Reputation: 7036

driver.findElement(By.xpath("//input[@name='buttonName' and @value='3.2']"));

Upvotes: 10

Related Questions