/** * Submits the form. * * Plain {@link HtmlForm#submit(com.gargoylesoftware.htmlunit.html.SubmittableElement)} doesn't work correctly due to the use of YUI in Hudson. */ public HtmlPage submit(HtmlForm form) throws Exception { return (HtmlPage) HtmlFormUtil.submit(form); }
/** * Submit the supplied {@link HtmlForm}. * <p> * Locates the submit element/button on the form. * @param htmlForm The {@link HtmlForm}. * @return The submit result page. * @throws IOException Error performing submit. */ public static Page submit(final HtmlForm htmlForm) throws IOException { HtmlElement submitElement = getSubmitButton(htmlForm); return submit(htmlForm, submitElement); }
/** * Submits the form. * * Plain {@link HtmlForm#submit(com.gargoylesoftware.htmlunit.html.SubmittableElement)} doesn't work correctly due to the use of YUI in Hudson. */ public HtmlPage submit(HtmlForm form) throws Exception { return (HtmlPage) HtmlFormUtil.submit(form, last(form.getElementsByTagName("button"))); }
/** * Submits the form by clikcing the submit button of the given name. * * @param name * This corresponds to the @name of {@code <f:submit />} */ public HtmlPage submit(HtmlForm form, String name) throws Exception { for( HtmlElement e : form.getElementsByTagName("button")) { HtmlElement p = (HtmlElement)e.getParentNode().getParentNode(); if (e instanceof HtmlButton && p.getAttribute("name").equals(name)) { return (HtmlPage)HtmlFormUtil.submit(form, (HtmlButton) e); } } throw new AssertionError("No such submit button with the name "+name); }
public HtmlPage search(String q) throws IOException, SAXException { HtmlPage top = goTo(""); HtmlForm search = top.getFormByName("search"); search.getInputByName("q").setValueAttribute(q); return (HtmlPage)HtmlFormUtil.submit(search, null); }
public HtmlPage search(String q) throws IOException, SAXException { HtmlPage top = goTo(""); HtmlForm search = top.getFormByName("search"); search.getInputByName("q").setValueAttribute(q); return (HtmlPage)HtmlFormUtil.submit(search, null); }
/** * Submits the form by clikcing the submit button of the given name. * * @param name * This corresponds to the @name of {@code <f:submit />} */ public HtmlPage submit(HtmlForm form, String name) throws Exception { for( HtmlElement e : form.getElementsByTagName("button")) { HtmlElement p = (HtmlElement)e.getParentNode().getParentNode(); if (p.getAttribute("name").equals(name) && HtmlElementUtil.hasClassName(p, "yui-submit-button")) { // For YUI handled submit buttons, just do a click. return (HtmlPage) HtmlElementUtil.click(e); } else if (e.getAttribute("name").equals(name)) { return (HtmlPage) HtmlFormUtil.submit(form, e); } } throw new AssertionError("No such submit button with the name "+name); }
/** * Logs in to Jenkins. */ public WebClient login(String username, String password) throws Exception { HtmlPage page = goTo("/login"); HtmlForm form = page.getFormByName("login"); form.getInputByName("j_username").setValueAttribute(username); form.getInputByName("j_password").setValueAttribute(password); HtmlFormUtil.submit(form, null); return this; }
/** * Logs in to Jenkins. */ public WebClient login(String username, String password, boolean rememberMe) throws Exception { HtmlPage page = goTo("login"); // page = (HtmlPage) page.getFirstAnchorByText("Login").click(); HtmlForm form = page.getFormByName("login"); form.getInputByName("j_username").setValueAttribute(username); form.getInputByName("j_password").setValueAttribute(password); try { form.getInputByName("remember_me").setChecked(rememberMe); } catch (ElementNotFoundException e) { // remember me not available is OK so long as the caller didn't ask for it assert !rememberMe; } HtmlFormUtil.submit(form, null); return this; }