/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br> * * Sets the selected state of this option. This will possibly also change the * selected properties of sibling option elements. * * @param selected true if this option should be selected */ public void setSelectedFromJavaScript(final boolean selected) { setSelected(selected, false, false, true, false); }
/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br> * * Sets the selected state of this option. This will possibly also change the * selected properties of sibling option elements. * * @param selected true if this option should be selected */ public void setSelectedFromJavaScript(final boolean selected) { setSelected(selected, false, false, true, false); }
/** * Sets the selected state of this option. This will possibly also change the * selected properties of sibling option elements. * * @param selected true if this option should be selected * @return the page that occupies this window after this change is made (may or * may not be the same as the original page) */ public Page setSelected(final boolean selected) { setSelected(selected, true, false, false, false); return getPage(); }
/** * Selects the option if it's not already selected. * {@inheritDoc} */ @Override protected Page doClickAction(final Page defaultPage) throws IOException { if (!isSelected()) { return setSelected(true); } return defaultPage; }
/** * Sets the selected state of this option. This will possibly also change the * selected properties of sibling option elements. * * @param selected true if this option should be selected * @return the page that occupies this window after this change is made (may or * may not be the same as the original page) */ public Page setSelected(final boolean selected) { setSelected(selected, true, false, false, false); return getPage(); }
/** * Selects the option if it's not already selected. * {@inheritDoc} */ @Override protected Page doClickAction(final Page defaultPage) throws IOException { if (!isSelected()) { return setSelected(true); } return defaultPage; }
/** * Sets the value of the "selected" property. * @param selected the new selected property */ public void jsxSet_selected(final boolean selected) { getDomNodeOrNull().setSelected(selected); }
/** * Sets the value of the "selected" property. * @param selected the new selected property */ public void jsxSet_selected(final boolean selected) { getDomNodeOrNull().setSelected(selected); }
/** * Sets the value of the "selected" property. * @param selected the new selected property */ public void jsxSet_selected(final boolean selected) { getDomNodeOrNull().setSelected(selected); }
/** * Selects the option if it's not already selected. * {@inheritDoc} */ @Override protected Page doClickAction(final Page defaultPage) throws IOException { if (!isSelected()) { return setSelected(true); } return defaultPage; }
public void setSelected() { assertElementNotStale(); String disabledValue = element.getAttribute("disabled"); if (disabledValue.length() > 0) { throw new UnsupportedOperationException("You may not select a disabled element"); } if (element instanceof HtmlInput) ((HtmlInput) element).setChecked(true); else if (element instanceof HtmlOption) ((HtmlOption) element).setSelected(true); else throw new UnsupportedOperationException("Unable to select element. Tag name is: " + element.getTagName()); }
/** * Selects the option if it's not already selected. * {@inheritDoc} */ @Override protected boolean doClickStateUpdate(final boolean shiftKey, final boolean ctrlKey) throws IOException { boolean changed = false; if (!isSelected()) { setSelected(true, true, true, shiftKey, ctrlKey); changed = true; } else if (getEnclosingSelect().isMultipleSelectEnabled()) { if (ctrlKey) { setSelected(false, true, true, shiftKey, ctrlKey); changed = true; } else { getEnclosingSelect().setOnlySelected(this, true); } } super.doClickStateUpdate(shiftKey, ctrlKey); return changed; }
/** * Selects the option if it's not already selected. * {@inheritDoc} */ @Override protected boolean doClickStateUpdate(final boolean shiftKey, final boolean ctrlKey) throws IOException { boolean changed = false; if (!isSelected()) { setSelected(true, true, true, shiftKey, ctrlKey); changed = true; } else if (getEnclosingSelect().isMultipleSelectEnabled()) { if (ctrlKey) { setSelected(false, true, true, shiftKey, ctrlKey); changed = true; } else { getEnclosingSelect().setOnlySelected(this, true); } } super.doClickStateUpdate(shiftKey, ctrlKey); return changed; }
/** * JavaScript constructor. This must be declared in every JavaScript file because * the rhino engine won't walk up the hierarchy looking for constructors. * @param newText the text * @param newValue the value * @param defaultSelected Whether the option is initially selected * @param selected the current selection state of the option */ public void jsConstructor(final String newText, final String newValue, final boolean defaultSelected, final boolean selected) { final HtmlPage page = (HtmlPage) getWindow().getWebWindow().getEnclosedPage(); AttributesImpl attributes = null; if (defaultSelected) { attributes = new AttributesImpl(); attributes.addAttribute(null, "selected", "selected", null, "selected"); } final HtmlOption htmlOption = (HtmlOption) HTMLParser.getFactory(HtmlOption.TAG_NAME).createElement( page, HtmlOption.TAG_NAME, attributes); htmlOption.setSelected(selected); setDomNode(htmlOption); if (newText != null && !newText.equals("undefined")) { htmlOption.appendChild(new DomText(page, newText)); } if (newValue != null && !newValue.equals("undefined")) { htmlOption.setValueAttribute(newValue); } }
/** * JavaScript constructor. * @param newText the text * @param newValue the value * @param defaultSelected Whether the option is initially selected * @param selected the current selection state of the option */ @JsxConstructor({CHROME, FF, EDGE}) public void jsConstructor(final String newText, final String newValue, final boolean defaultSelected, final boolean selected) { final HtmlPage page = (HtmlPage) getWindow().getWebWindow().getEnclosedPage(); AttributesImpl attributes = null; if (defaultSelected) { attributes = new AttributesImpl(); attributes.addAttribute(null, "selected", "selected", null, "selected"); } final HtmlOption htmlOption = (HtmlOption) HTMLParser.getFactory(HtmlOption.TAG_NAME).createElement( page, HtmlOption.TAG_NAME, attributes); htmlOption.setSelected(selected); setDomNode(htmlOption); if (!"undefined".equals(newText)) { htmlOption.appendChild(new DomText(page, newText)); htmlOption.setLabelAttribute(newText); } if (!"undefined".equals(newValue)) { htmlOption.setValueAttribute(newValue); } }
public boolean toggle() { assertElementNotStale(); try { if (element instanceof HtmlCheckBoxInput) { ((HtmlCheckBoxInput) element).click(); return isSelected(); } if (element instanceof HtmlOption) { HtmlOption option = (HtmlOption) element; HtmlSelect select = option.getEnclosingSelect(); if (select.isMultipleSelectEnabled()) { option.setSelected(!option.isSelected()); return isSelected(); } } throw new UnsupportedOperationException("You may only toggle checkboxes or options in a select which allows multiple selections: " + getTagName()); } catch (IOException e) { throw new WebDriverException("Unexpected exception: " + e); } }
/** * Sets the "selected" state of the specified option. If this "select" element * is single-select, then calling this method will deselect all other options. * * Only options that are actually in the document may be selected. * * @param isSelected true if the option is to become selected * @param optionValue the value of the option that is to change * @return the page that occupies this window after this change is made (may or * may not be the same as the original page) */ public Page setSelectedAttribute(final String optionValue, final boolean isSelected) { try { return setSelectedAttribute(getOptionByValue(optionValue), isSelected); } catch (final ElementNotFoundException e) { if (getPage().getWebClient().getBrowserVersion().isIE()) { for (final HtmlOption o : getSelectedOptions()) { o.setSelected(false); } } return getPage(); } }
/** * Sets the "selected" state of the specified option. If this "select" element * is single-select, then calling this method will deselect all other options. * * Only options that are actually in the document may be selected. * * @param isSelected true if the option is to become selected * @param optionValue the value of the option that is to change * @return the page that occupies this window after this change is made (may or * may not be the same as the original page) */ public Page setSelectedAttribute(final String optionValue, final boolean isSelected) { try { return setSelectedAttribute(getOptionByValue(optionValue), isSelected); } catch (final ElementNotFoundException e) { if (getPage().getWebClient().getBrowserVersion().isIE()) { for (final HtmlOption o : getSelectedOptions()) { o.setSelected(false); } } return getPage(); } }
/** * Sets the "selected" state of the specified option. If this "select" element * is single-select, then calling this method will deselect all other options. * * Only options that are actually in the document may be selected. * * @param isSelected true if the option is to become selected * @param optionValue the value of the option that is to change * @return the page that occupies this window after this change is made (may or * may not be the same as the original page) */ public Page setSelectedAttribute(final String optionValue, final boolean isSelected) { try { return setSelectedAttribute(getOptionByValue(optionValue), isSelected); } catch (final ElementNotFoundException e) { if (getPage().getWebClient().getBrowserVersion().isIE()) { for (final HtmlOption o : getSelectedOptions()) { o.setSelected(false); } } return getPage(); } }
private HtmlPage restartFromStageInUI(@Nonnull WorkflowRun original, @Nonnull String stageName) throws Exception { RestartDeclarativePipelineAction action = original.getAction(RestartDeclarativePipelineAction.class); assertNotNull(action); assertTrue(action.isRestartEnabled()); HtmlPage page = j.createWebClient().getPage(original, action.getUrlName()); HtmlForm form = page.getFormByName("restart"); HtmlSelect select = form.getSelectByName("stageName"); select.getOptionByValue(stageName).setSelected(true); return j.submit(form); }