@Override Object getInternalValue() { return isChecked(); }
/** * A radio button does not have a textual representation, * but we invent one for it because it is useful for testing. * @return "checked" or "unchecked" according to the radio state */ // we need to preserve this method as it is there since many versions with the above documentation. @Override public String asText() { if (isChecked()) { return "checked"; } return "unchecked"; }
/** * A radio button does not have a textual representation, * but we invent one for it because it is useful for testing. * @return "checked" or "unchecked" according to the radio state */ // we need to preserve this method as it is there since many versions with the above documentation. @Override public String asText() { if (isChecked()) { return "checked"; } return "unchecked"; }
/** * A radio button does not have a textual representation, * but we invent one for it because it is useful for testing. * @return "checked" or "unchecked" according to the radio state */ // we need to preserve this method as it is there since many versions with the above documentation. @Override public String asText() { if (isChecked()) { return "checked"; } return "unchecked"; }
@Override Object getInternalValue() { return isChecked(); }
/** * Process {@link HtmlRadioButtonInput}. * * @param builder the StringBuilder to add to * @param htmlRadioButtonInput the target to process */ protected void doAppendRadioButtonInput(final StringBuilder builder, final HtmlRadioButtonInput htmlRadioButtonInput) { if (htmlRadioButtonInput.isChecked()) { builder.append("checked"); } else { builder.append("unchecked"); } }
/** * Process {@link HtmlRadioButtonInput}. * * @param builder the StringBuilder to add to * @param htmlRadioButtonInput the target to process */ protected void doAppendRadioButtonInput(final StringBuilder builder, final HtmlRadioButtonInput htmlRadioButtonInput) { if (htmlRadioButtonInput.isChecked()) { builder.append("checked"); } else { builder.append("unchecked"); } }
/** * Clicks a radio option. Asserts that the radio option exists first. * * * @param radioGroup name of the radio group. * @param radioOption value of the option to check for. */ @Override public void clickRadioOption(String radioGroup, String radioOption) { HtmlRadioButtonInput rb = getRadioOption(radioGroup, radioOption); if (!rb.isChecked()) { try { rb.click(); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("checkCheckbox failed", e); } } }
/** * {@inheritDoc} */ @Override protected void onAddedToPage() { super.onAddedToPage(); setChecked(isChecked()); }
/** * {@inheritDoc} */ @Override protected void onAddedToPage() { super.onAddedToPage(); setChecked(isChecked()); }
/** * Returns the first checked radio button with the specified name. If none of * the radio buttons by that name are checked, this method returns <tt>null</tt>. * * @param name the name of the radio button * @return the first checked radio button with the specified name */ public HtmlRadioButtonInput getCheckedRadioButton(final String name) { WebAssert.notNull("name", name); for (final HtmlRadioButtonInput input : getRadioButtonsByName(name)) { if (input.isChecked()) { return input; } } return null; }
/** * Returns the first checked radio button with the specified name. If none of * the radio buttons by that name are checked, this method returns {@code null}. * * @param name the name of the radio button * @return the first checked radio button with the specified name */ public HtmlRadioButtonInput getCheckedRadioButton(final String name) { WebAssert.notNull("name", name); for (final HtmlRadioButtonInput input : getRadioButtonsByName(name)) { if (input.isChecked()) { return input; } } return null; }
@Override public String getSelectedRadio(String radioGroup) { List<HtmlRadioButtonInput> radios = getForm().getRadioButtonsByName(radioGroup); for (HtmlRadioButtonInput radio : radios) { if (radio.isChecked()) { return radio.getValueAttribute(); } } throw new RuntimeException("Unexpected state: no radio button was selected in radio group [" + radioGroup + "]. Is it possible in a real browser?"); }
/** * Returns the first checked radio button with the specified name. If none of * the radio buttons by that name are checked, this method returns <tt>null</tt>. * * @param name the name of the radio button * @return the first checked radio button with the specified name */ public HtmlRadioButtonInput getCheckedRadioButton(final String name) { WebAssert.notNull("name", name); for (final HtmlRadioButtonInput input : getRadioButtonsByName(name)) { if (input.isChecked()) { return input; } } return null; }
/** * Returns the first checked radio button with the specified name. If none of * the radio buttons by that name are checked, this method returns {@code null}. * * @param name the name of the radio button * @return the first checked radio button with the specified name */ public HtmlRadioButtonInput getCheckedRadioButton(final String name) { WebAssert.notNull("name", name); for (final HtmlRadioButtonInput input : getRadioButtonsByName(name)) { if (input.isChecked()) { return input; } } return null; }
/** * Returns the first checked radio button with the specified name. If none of * the radio buttons by that name are checked, this method returns <tt>null</tt>. * * @param name the name of the radio button * @return the first checked radio button with the specified name */ public HtmlRadioButtonInput getCheckedRadioButton(final String name) { WebAssert.notNull("name", name); for (final HtmlRadioButtonInput input : getRadioButtonsByName(name)) { if (input.isChecked()) { return input; } } return null; }
/** * Override of default clickAction that makes this radio button the selected * one when it is clicked. * {@inheritDoc} * * @throws IOException if an IO error occurred */ @Override protected boolean doClickStateUpdate(final boolean shiftKey, final boolean ctrlKey) throws IOException { final HtmlForm form = getEnclosingForm(); final boolean changed = !isChecked(); final Page page = getPage(); if (form != null) { form.setCheckedRadioButton(this); } else if (page != null && page.isHtmlPage()) { setCheckedForPage((HtmlPage) page); } super.doClickStateUpdate(shiftKey, ctrlKey); return changed; }
/** * Override of default clickAction that makes this radio button the selected * one when it is clicked. * {@inheritDoc} * * @throws IOException if an IO error occurred */ @Override protected boolean doClickStateUpdate(final boolean shiftKey, final boolean ctrlKey) throws IOException { final HtmlForm form = getEnclosingForm(); final boolean changed = !isChecked(); final Page page = getPage(); if (form != null) { form.setCheckedRadioButton(this); } else if (page != null && page.isHtmlPage()) { setCheckedForPage((HtmlPage) page); } super.doClickStateUpdate(shiftKey, ctrlKey); return changed; }
/** * Add a GerritServer with default configs from the UI. * * @param serverName the name * @throws Exception if error getting URL or getting page from URL. */ private void addNewServerWithDefaultConfigs(String serverName) throws Exception { URL url = new URL(j.getURL(), newServerURL); HtmlPage page = j.createWebClient().getPage(url); HtmlForm form = page.getFormByName(newServerFormName); form.getInputByName(inputFormName).setValueAttribute(serverName); List<HtmlRadioButtonInput> radioButtons = form.getRadioButtonsByName(radioButtonName); HtmlRadioButtonInput radioButtonDefaultConfig = null; for (HtmlRadioButtonInput button : radioButtons) { if (radioButtonDefaultConfigValue.equals(button.getValueAttribute())) { radioButtonDefaultConfig = button; radioButtonDefaultConfig.setChecked(true); } } assertTrue("Failed to choose 'GerritServer with Default Configurations'", radioButtonDefaultConfig.isChecked()); j.submit(form); }
/** * Add a GerritServer by copying existing configs from the UI. * * @param newServerName the name of the new server * @param fromServerName the name of the server from which the config is copied. * @throws Exception if error getting URL or getting page from URL. */ private void addNewServerByCopyingConfig(String newServerName, String fromServerName) throws Exception { URL url = new URL(j.getURL(), newServerURL); HtmlPage page = j.createWebClient().getPage(url); HtmlForm form = page.getFormByName(newServerFormName); form.getInputByName(inputFormName).setValueAttribute(newServerName); List<HtmlRadioButtonInput> radioButtons = form.getRadioButtonsByName(radioButtonName); HtmlRadioButtonInput radioButtonCopy = null; for (HtmlRadioButtonInput button : radioButtons) { if (radioButtonCopyValue.equals(button.getValueAttribute())) { radioButtonCopy = button; radioButtonCopy.setChecked(true); } } assertTrue("Failed to choose 'Copy from Existing Server Configurations'", radioButtonCopy.isChecked()); form.getInputByName(fromInputFormName).setValueAttribute(fromServerName); j.submit(form); }