use of com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput in project posters-advanced-loadtest-suite by Xceptance.
the class FormUtils method checkRadioButton.
public static HtmlRadioButtonInput checkRadioButton(final HtmlRadioButtonInput radioButton) {
// Remove checked state from previously checked radio button
final HtmlForm form = radioButton.getEnclosingForm();
if (form != null) {
final LookUpResult previouslyChecked = HPU.find().in(form).byCss("[name='" + radioButton.getNameAttribute() + "'][checked]");
if (previouslyChecked.exists()) {
final HtmlRadioButtonInput oldRadioButton = previouslyChecked.single();
oldRadioButton.setChecked(false);
oldRadioButton.removeAttribute("checked");
}
} else {
// Comment the next line if you know what you're doing only.
Assert.fail("RadioButton is NOT inside a form. This might be due to broken HTML. It's strongly recommended to fix HTML issues first, then continue testing.");
}
// Check current radio button
radioButton.setChecked(true);
radioButton.setAttribute("checked", "checked");
if (isNotLoadTestMode) {
XltLogger.runTimeLogger.info(String.format("Checking radio button: %s", getIdOrName(radioButton)));
}
return radioButton;
}
Aggregations