答案选择的HTML是
A
<input id="A" type="radio" onclick="javascript:ValidateAns(53209,0,9, 'A')" name="AnsChoice" value="A"/>
<label for="A">145</label>
<br/>
<br/>
B
<input id="B" type="radio" onclick="javascript:ValidateAns(53209,0,9, 'B')" name="AnsChoice" value="B"/>
<label for="B">148</label>
<br/>
<br/>
C
<input id="C" type="radio" onclick="javascript:ValidateAns(53209,0,9, 'C')" name="AnsChoice" value="C"/>
<label for="C">143</label>
<br/>
<br/>
D
<input id="D" type="radio" onclick="javascript:ValidateAns(53209,0,9, 'D')" name="AnsChoice" value="D"/>
<label for="D">155</label>
答案 0 :(得分:2)
不是WebDriver问题。
Random rnd = new Random();
List<WebElement> radios = driver.findElements(By.xpath("//input"));
radios.get(rnd.nextInt(radios.size())).click();