Java Code Examples for com.gargoylesoftware.htmlunit.html.HtmlForm#getElementsByTagName()
The following examples show how to use
com.gargoylesoftware.htmlunit.html.HtmlForm#getElementsByTagName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JenkinsRule.java From jenkins-test-harness with MIT License | 5 votes |
/** * Submits the form by clicking 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); }
Example 2
Source File: JenkinsRule.java From jenkins-test-harness with MIT License | 5 votes |
public HtmlButton getButtonByCaption(HtmlForm f, String s) { for (HtmlElement b : f.getElementsByTagName("button")) { if(b.getTextContent().trim().equals(s)) return (HtmlButton)b; } return null; }
Example 3
Source File: HudsonTestCase.java From jenkins-test-harness with MIT License | 5 votes |
/** * Submits the form by clicking 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); }
Example 4
Source File: HudsonTestCase.java From jenkins-test-harness with MIT License | 5 votes |
protected HtmlButton getButtonByCaption(HtmlForm f, String s) { for (HtmlElement b : f.getElementsByTagName("button")) { if(b.getTextContent().trim().equals(s)) return (HtmlButton)b; } return null; }