div
のすべてのlabel
アイテムをループする方法私はラジオボタンを持っているinturnのラベルタグの未知数の束があることを意味します。 Selenium WebDriverを使用してください。私は選択したradio button
を見つける必要があります。二つのものがここにありますのリストで選択したラジオボタンをセレンのwebdriverを使用して検索します
- 私は
<div class="controls"> \t <label class="radio inline"> \t \t <input type="radio" value="0" name="PlaceOfResidence"/> \t Urban \t </label> \t <label class="radio inline"> \t \t <input type="radio" value="1" name="PlaceOfResidence"/> \t Suburb \t </label> \t <label class="radio inline"> \t \t <input type="radio" value="2" name="PlaceOfResidence"/> \t Rural \t </label> \t <label class="radio inline"> \t \t <input type="radio" value="3" name="PlaceOfResidence"/> \t Not Available \t </label> </div>
たとえば、選択した無線要素
を見つける必要がありラジオ要素
private String isRadioButtonSelected2(String name){
List<WebElement> webEl = this.getWrappedDriver().findElements(By.xpath("//input[@type='radio' and @name = '"+name+"']/parent::label")); //and @value='"+value+"']"));
String selectedValue = "";
for(WebElement element: webEl){
Boolean selectedRadio = element.isSelected();
if(selectedRadio){
selectedValue =this.getWrappedDriver().findElement(By.xpath("//input[@type='radio' and @name = '"+name+"']/parent::label")).getText();
log("&&&&&&&&&&"+selectedValue);
}else{
return null;
}
}
return selectedValue;
}
を!私はサイズを繰り返し、isSelected() – shockwave