protected HtmlInput getInputByName(HtmlForm f, String name) { for (HtmlElement b : f.getHtmlElementsByTagName("button")) { if (b.getAttribute("name").equals(name)) { return (HtmlInput) b; } } return null; }
protected HtmlButton getButtonByCaption(HtmlForm f, String s) { for (HtmlElement b : f.getHtmlElementsByTagName("button")) { if(b.getTextContent().trim().equals(s)) return (HtmlButton)b; } return null; }
protected HtmlButton getButtonByCaption(HtmlForm f, String s) { for (HtmlElement b : f.getHtmlElementsByTagName("button")) { if(b.getTextContent().trim().equals(s)) return (HtmlButton)b; } return null; }
protected HtmlButton getButtonByCaption(HtmlForm f, String s) { for (HtmlElement b : f.getHtmlElementsByTagName("button")) { if (b.getTextContent().trim().equals(s)) { return (HtmlButton) b; } } return null; }
public HtmlButton getButtonByCaption(final String caption) throws ElementNotFoundException { for (HtmlElement b : getHtmlElementsByTagName("button")) { if(b.getTextContent().trim().equals(caption)) return (HtmlButton)b; } throw new ElementNotFoundException("button", "caption", caption); }
public HtmlButton getButtonByCaption(final String caption) throws ElementNotFoundException { for (HtmlElement b : getHtmlElementsByTagName("button")) { if(b.getTextContent().trim().equals(caption)) return (HtmlButton)b; } throw new ElementNotFoundException("button", "caption", caption); }
/** * Submits the form. * * Plain {@link HtmlForm#submit()} doesn't work correctly due to the use of * YUI in Hudson. */ public HtmlPage submit(HtmlForm form) throws Exception { List<HtmlButton> buttons = form.getHtmlElementsByTagName("button"); if ((buttons != null) && (buttons.size() > 0)) { HtmlButton button = (HtmlButton) last(form.getHtmlElementsByTagName("button")); return (HtmlPage) form.submit(button); } else { return (HtmlPage) form.submit(); } }
/** * Submits the form. * * Plain {@link HtmlForm#submit()} doesn't work correctly due to the use of YUI in Hudson. */ public HtmlPage submit(HtmlForm form) throws Exception { return (HtmlPage)form.submit((HtmlButton)last(form.getHtmlElementsByTagName("button"))); }
/** * Submits the form. * * Plain {@link HtmlForm#submit()} doesn't work correctly due to the use of YUI in Hudson. */ public HtmlPage submit(HtmlForm form) throws Exception { return (HtmlPage)form.submit((HtmlButton)last(form.getHtmlElementsByTagName("button"))); }
/** * Submits the form by clikcing the submit button of the given name. * * @param name * This corresponds to the @name of <f:submit /> */ public HtmlPage submit(HtmlForm form, String name) throws Exception { for( HtmlElement e : form.getHtmlElementsByTagName("button")) { HtmlElement p = (HtmlElement)e.getParentNode().getParentNode(); if(p.getAttribute("name").equals(name)) { // To make YUI event handling work, this combo seems to be necessary // the click will trigger _onClick in buton-*.js, but it doesn't submit the form // (a comment alluding to this behavior can be seen in submitForm method) // so to complete it, submit the form later. // // Just doing form.submit() doesn't work either, because it doesn't do // the preparation work needed to pass along the name of the button that // triggered a submission (more concretely, m_oSubmitTrigger is not set.) ((HtmlButton)e).click(); return (HtmlPage)form.submit((HtmlButton)e); } } throw new AssertionError("No such submit button with the name "+name); }
/** * Submits the form by clikcing the submit button of the given name. * * @param name * This corresponds to the @name of <f:submit /> */ public HtmlPage submit(HtmlForm form, String name) throws Exception { for( HtmlElement e : form.getHtmlElementsByTagName("button")) { HtmlElement p = (HtmlElement)e.getParentNode().getParentNode(); if(p.getAttribute("name").equals(name)) { // To make YUI event handling work, this combo seems to be necessary // the click will trigger _onClick in buton-*.js, but it doesn't submit the form // (a comment alluding to this behavior can be seen in submitForm method) // so to complete it, submit the form later. // // Just doing form.submit() doesn't work either, because it doesn't do // the preparation work needed to pass along the name of the button that // triggered a submission (more concretely, m_oSubmitTrigger is not set.) ((HtmlButton)e).click(); return (HtmlPage)form.submit((HtmlButton)e); } } throw new AssertionError("No such submit button with the name "+name); }
for (HtmlElement e : form.getHtmlElementsByTagName("button")) { HtmlElement p = (HtmlElement) e.getParentNode().getParentNode(); if (p.getAttribute("name").equals(name)) { for (HtmlElement e : form.getHtmlElementsByTagName("input")) { if (e.getAttribute("name").equals(name)) { ((HtmlInput) e).click();
/** * Remove Server from UI. * @param serverName the name of the Gerrit server you want to access. * @return true if the form had a button and was posted * @throws Exception if error removing server. */ private boolean removeServer(String serverName) throws Exception { URL url = new URL(j.getURL(), Functions.joinPath(serverURL, "server", serverName, "remove")); HtmlPage removalPage = j.createWebClient().getPage(url); HtmlForm form = removalPage.getFormByName(removalFormName); List<HtmlElement> buttons = form.getHtmlElementsByTagName("button"); textContent = form.getTextContent(); if (buttons.size() >= 1) { j.submit(form); return true; } else { return false; } }