Class HtmlFormUtil

java.lang.Object
org.htmlunit.html.HtmlFormUtil

public class HtmlFormUtil extends Object
HtmlForm helper functions.

In many cases, the methods defined here replace methods of the same name that were added to the HtmlForm class on the old forked version of HtmlUnit.

Author:
tom.fennelly@gmail.com
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.htmlunit.html.HtmlButton
    getButtonByCaption(org.htmlunit.html.HtmlForm htmlForm, String caption)
    Get the form button having the specified text/caption.
    static org.htmlunit.html.HtmlElement
    getSubmitButton(org.htmlunit.html.HtmlForm htmlForm)
    Gets the first <button class="jenkins-submit-button"> element in this form.
    static List<org.htmlunit.html.HtmlElement>
    getSubmitButtons(org.htmlunit.html.HtmlForm htmlForm)
    Returns all the <input type="submit"> elements in this form.
    static org.htmlunit.Page
    submit(org.htmlunit.html.HtmlForm htmlForm)
    Submit the supplied HtmlForm.
    static org.htmlunit.Page
    submit(org.htmlunit.html.HtmlForm htmlForm, org.htmlunit.html.HtmlElement submitElement)
    Submit the supplied HtmlForm via the supplied submit element.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • submit

      public static org.htmlunit.Page submit(org.htmlunit.html.HtmlForm htmlForm) throws IOException
      Submit the supplied HtmlForm.

      Locates the submit element/button on the form.

      Parameters:
      htmlForm - The HtmlForm.
      Returns:
      The submit result page.
      Throws:
      IOException - Error performing submit.
    • submit

      public static org.htmlunit.Page submit(org.htmlunit.html.HtmlForm htmlForm, org.htmlunit.html.HtmlElement submitElement) throws IOException
      Submit the supplied HtmlForm via the supplied submit element.
      Parameters:
      htmlForm - The HtmlForm.
      submitElement - The element through which the submit should be performed.
      Returns:
      The submit result page.
      Throws:
      IOException - Error performing submit.
    • getSubmitButtons

      public static List<org.htmlunit.html.HtmlElement> getSubmitButtons(org.htmlunit.html.HtmlForm htmlForm) throws org.htmlunit.ElementNotFoundException
      Returns all the <input type="submit"> elements in this form.
      Throws:
      org.htmlunit.ElementNotFoundException
    • getSubmitButton

      public static org.htmlunit.html.HtmlElement getSubmitButton(org.htmlunit.html.HtmlForm htmlForm) throws org.htmlunit.ElementNotFoundException
      Gets the first <button class="jenkins-submit-button"> element in this form. If not found, then it looks for the first <input type="submit"> or <button name="Submit"> or <button> (in that order).
      Throws:
      org.htmlunit.ElementNotFoundException
    • getButtonByCaption

      public static org.htmlunit.html.HtmlButton getButtonByCaption(org.htmlunit.html.HtmlForm htmlForm, String caption) throws org.htmlunit.ElementNotFoundException
      Get the form button having the specified text/caption.
      Parameters:
      htmlForm - The form containing the button.
      caption - The button text/caption being searched for.
      Returns:
      The button if found.
      Throws:
      org.htmlunit.ElementNotFoundException - Failed to find the button on the form.