How to find a switch item by value using Selenium?

So far, I just liked:

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

radioButton4.click

but now I want to find the 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 this?

+8
source share
4 answers
driver.findElement(By.xpath("//input[@name='buttonName' and @value='3.2']"));
+6
source

If you want to search only by value, use

driver.findElement(By.xpath("//input[@value='3.2']"));
+6
source
driver.FindElement(By.cssSelector(input[type='radio'][value='3.2']));
+3
source

In python it is

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

0
source

Source: https://habr.com/ru/post/1621107/


All Articles