Class 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
    • Constructor Summary

      Constructors 
      Constructor Description
      HtmlFormUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.gargoylesoftware.htmlunit.html.HtmlButton getButtonByCaption​(com.gargoylesoftware.htmlunit.html.HtmlForm htmlForm, String caption)
      Get the form button having the specified text/caption.
      static com.gargoylesoftware.htmlunit.html.HtmlElement getSubmitButton​(com.gargoylesoftware.htmlunit.html.HtmlForm htmlForm)
      Gets the first <input type="submit"> element in this form.
      static List<com.gargoylesoftware.htmlunit.html.HtmlElement> getSubmitButtons​(com.gargoylesoftware.htmlunit.html.HtmlForm htmlForm)
      Returns all the <input type="submit"> elements in this form.
      static com.gargoylesoftware.htmlunit.Page submit​(com.gargoylesoftware.htmlunit.html.HtmlForm htmlForm)
      Submit the supplied HtmlForm.
      static com.gargoylesoftware.htmlunit.Page submit​(com.gargoylesoftware.htmlunit.html.HtmlForm htmlForm, com.gargoylesoftware.htmlunit.html.HtmlElement submitElement)
      Submit the supplied HtmlForm via the supplied submit element.
    • Constructor Detail

      • HtmlFormUtil

        public HtmlFormUtil()
    • Method Detail

      • submit

        public static com.gargoylesoftware.htmlunit.Page submit​(com.gargoylesoftware.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 com.gargoylesoftware.htmlunit.Page submit​(com.gargoylesoftware.htmlunit.html.HtmlForm htmlForm,
                                                                com.gargoylesoftware.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<com.gargoylesoftware.htmlunit.html.HtmlElement> getSubmitButtons​(com.gargoylesoftware.htmlunit.html.HtmlForm htmlForm)
                                                                                     throws com.gargoylesoftware.htmlunit.ElementNotFoundException
        Returns all the <input type="submit"> elements in this form.
        Throws:
        com.gargoylesoftware.htmlunit.ElementNotFoundException
      • getSubmitButton

        public static com.gargoylesoftware.htmlunit.html.HtmlElement getSubmitButton​(com.gargoylesoftware.htmlunit.html.HtmlForm htmlForm)
                                                                              throws com.gargoylesoftware.htmlunit.ElementNotFoundException
        Gets the first <input type="submit"> element in this form.
        Throws:
        com.gargoylesoftware.htmlunit.ElementNotFoundException
      • getButtonByCaption

        public static com.gargoylesoftware.htmlunit.html.HtmlButton getButtonByCaption​(com.gargoylesoftware.htmlunit.html.HtmlForm htmlForm,
                                                                                       String caption)
                                                                                throws com.gargoylesoftware.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:
        com.gargoylesoftware.htmlunit.ElementNotFoundException - Failed to find the button on the form.