Class FormInputValueHelper


  • public final class FormInputValueHelper
    extends Object
    Singleton helper class for FormHandler.
    • Constructor Detail

      • FormInputValueHelper

        private FormInputValueHelper​(InputSpecification inputSpecification,
                                     CrawlRules.FormFillMode formFillMode)
        Parameters:
        inputSpecification - the input specification.
        formFillMode - if random data should be used on the input fields.
    • Method Detail

      • getInstance

        public static FormInputValueHelper getInstance​(InputSpecification inputSpecification,
                                                       CrawlRules.FormFillMode formFillMode)
        Creates or returns the instance of the helper class.
        Parameters:
        inputSpecification - the input specification.
        formFillMode - if random data should be used on the input fields.
        Returns:
        The singleton instance.
      • reset

        public static void reset()
        Removes the instance so another must be built. Used only to reset the state in between JUnit tests.
      • serializeFormInputs

        public static void serializeFormInputs​(File dir)
        Serializes form inputs and writes the data to the output directory to be used by future non-training crawls.
        Parameters:
        dir - The output directory for the form input data.
      • deserializeFormInputs

        public static List<FormInput> deserializeFormInputs​(File dir)
        Serializes form inputs and writes the data to the output directory to be used by future non-training crawls.
        Parameters:
        dir - The output directory for the form input data.
        Returns:
        The list of inputs
      • getMaxNumberOfValues

        private int getMaxNumberOfValues​(List<FormInput> fieldNames)
      • getCandidateElementsForInputs

        public List<CandidateElement> getCandidateElementsForInputs​(EmbeddedBrowser browser,
                                                                    Element sourceElement,
                                                                    EventableCondition eventableCondition)
        Parameters:
        browser - the browser instance
        sourceElement - the form elements
        eventableCondition - the belonging eventable condition for sourceElement
        Returns:
        a list with Candidate elements for the inputs
      • getIdentification

        private Identification getIdentification​(Node element)
        Parameters:
        element -
        Returns:
        returns the id of the element if set, else the name. If none found, returns xpath
      • addTrainingInput

        public void addTrainingInput​(Identification identification,
                                     FormInput input)
        Add the training data to the form input map.
        Parameters:
        identification - The identifier.
        input - The form input.
      • getFormInput

        public FormInput getFormInput​(Identification identification)
        Get the form input for the DOM element.
        Parameters:
        identification - specifies a DOM element
        Returns:
        the form input for the DOM element.
      • getFormInputWithIndexValue

        public FormInput getFormInputWithIndexValue​(EmbeddedBrowser browser,
                                                    Node element,
                                                    int indexValue)
        Parameters:
        browser - the current browser instance
        element - the element in the DOM
        indexValue - the i-th specified value. if i>#values, first value is used
        Returns:
        the specified value with index indexValue for the belonging elements
      • formInputMatchingNode

        private FormInput formInputMatchingNode​(Node element)
        return the list of FormInputs that match this element
        Parameters:
        element -
        Returns:
      • getElementType

        private String getElementType​(Node node)