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:
但现在我想按值找到元素,这个值:
So I want to go:
所以我想去:
val radioButton4: WebElement = driver.findElement(By.value("3.2"))
radioButton4.click
How can I do that?
我怎样才能做到这一点?
3 个解决方案
#1
6
driver.findElement(By.xpath("//input[@name='buttonName' and @value='3.2']"));
#2
6
If you want to find only by value then use,
如果您只想按价值找到然后使用,
driver.findElement(By.xpath("//input[@value='3.2']"));
#3
3
driver.FindElement(By.cssSelector(input[type='radio'][value='3.2']));
#1
6
driver.findElement(By.xpath("//input[@name='buttonName' and @value='3.2']"));
#2
6
If you want to find only by value then use,
如果您只想按价值找到然后使用,
driver.findElement(By.xpath("//input[@value='3.2']"));
#3
3
driver.FindElement(By.cssSelector(input[type='radio'][value='3.2']));