/** * Select the specified radio button in the page (outside any <form>). * * @param radioButtonInput the radio Button */ private void setCheckedForPage(final HtmlPage htmlPage) { // May be done in single XPath search? final List<HtmlRadioButtonInput> pageInputs = htmlPage.getByXPath("//input[lower-case(@type)='radio' " + "and @name='" + getNameAttribute() + "']"); final List<HtmlRadioButtonInput> formInputs = htmlPage.getByXPath("//form//input[lower-case(@type)='radio' " + "and @name='" + getNameAttribute() + "']"); pageInputs.removeAll(formInputs); boolean foundInPage = false; for (final HtmlRadioButtonInput input : pageInputs) { if (input == this) { setCheckedInternal(true); foundInPage = true; } else { input.setCheckedInternal(false); } } if (!foundInPage && !formInputs.contains(this)) { setCheckedInternal(true); } }
/** * Select the specified radio button in the page (outside any <form>). * * @param radioButtonInput the radio Button */ private void setCheckedForPage(final HtmlPage htmlPage) { // May be done in single XPath search? final List<HtmlRadioButtonInput> pageInputs = htmlPage.getByXPath("//input[lower-case(@type)='radio' " + "and @name='" + getNameAttribute() + "']"); final List<HtmlRadioButtonInput> formInputs = htmlPage.getByXPath("//form//input[lower-case(@type)='radio' " + "and @name='" + getNameAttribute() + "']"); pageInputs.removeAll(formInputs); boolean foundInPage = false; for (final HtmlRadioButtonInput input : pageInputs) { if (input == this) { setCheckedInternal(true); foundInPage = true; } else { input.setCheckedInternal(false); } } if (!foundInPage && !formInputs.contains(this)) { setCheckedInternal(true); } }
/** * Selects the specified radio button in the form. Only a radio button that is actually contained * in the form can be selected. * * @param radioButtonInput the radio button to select */ void setCheckedRadioButton(final HtmlRadioButtonInput radioButtonInput) { if (!isAncestorOf(radioButtonInput) && !lostChildren_.contains(radioButtonInput)) { throw new IllegalArgumentException("HtmlRadioButtonInput is not child of this HtmlForm"); } final List<HtmlRadioButtonInput> radios = getRadioButtonsByName(radioButtonInput.getNameAttribute()); for (final HtmlRadioButtonInput input : radios) { input.setCheckedInternal(input == radioButtonInput); } }
/** * Selects the specified radio button in the form. Only a radio button that is actually contained * in the form can be selected. * * @param radioButtonInput the radio button to select */ void setCheckedRadioButton(final HtmlRadioButtonInput radioButtonInput) { if (!isAncestorOf(radioButtonInput) && !lostChildren_.contains(radioButtonInput)) { throw new IllegalArgumentException("HtmlRadioButtonInput is not child of this HtmlForm"); } final List<HtmlRadioButtonInput> radios = getRadioButtonsByName(radioButtonInput.getNameAttribute()); for (final HtmlRadioButtonInput input : radios) { input.setCheckedInternal(input == radioButtonInput); } }