【发布时间】:2015-08-22 09:52:32
【问题描述】:
如何设置条件来执行多个单选按钮点击(见下图)...?
我已经尝试了几个小时,但我只有一个单选按钮点击(见附图)
List<WebElement> radiobutton = driver.findElements(By.xpath("//*[@type='radio']"));
System.out.println("Total element is " + radiobutton.size());
for (int i = 0; i < radiobutton.size(); i++) {
// if you are getting stale element exception because of the page
// reload
radiobutton = driver.findElements(By.xpath("//*[@type='radio']"));
System.out.println(radiobutton.get(i).getAttribute("value"));
// select your radio and click to go to next page
radiobutton.get(i).click();
Thread.sleep(3000);
driver.findElement(By.xpath("//input[@id='btnCheckFare']"))
.click();
Thread.sleep(3000);
}
【问题讨论】:
-
为什么不表明你已经尝试过了。
-
一组中只能选择一个单选按钮!你的意思是一一选择吗?并发布 HTML 以获得更好的响应。
-
您可以在此视频中看到使用人工交互的多个单选按钮youtu.be/KxydkdhNdYc?t=143
标签: java selenium selenium-webdriver radio-button