16

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?

Joe
  • 2,543
  • 3
  • 25
  • 49

4 Answers4

14

If you want to find only by value then use,

driver.findElement(By.xpath("//input[@value='3.2']"));
Bharat DEVre
  • 539
  • 3
  • 13
10
driver.findElement(By.xpath("//input[@name='buttonName' and @value='3.2']"));
Termininja
  • 6,620
  • 12
  • 48
  • 49
5
driver.FindElement(By.cssSelector(input[type='radio'][value='3.2']));
Shoby
  • 103
  • 2
  • 10
4

In python, it's

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

rvictordelta
  • 630
  • 2
  • 8
  • 23
  • This does not work in the latest version and I have not found anything in the documentation that explains how to use it. Any suggestions? – Arete Jan 04 '22 at 15:02