Class TrainingFormHandler


  • public class TrainingFormHandler
    extends FormHandler
    Creates form value templates by pausing the crawl and allowing the user to manually enter form formInputs.
    Author:
    qhanam
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • MODAL_HTML

        private static final String MODAL_HTML
        The HTML to display when the crawl is paused for form input.
        See Also:
        Constant Field Values
      • visited

        private static final Set<Identification> visited
        Keeps track of the form data manually entered during training.
    • Method Detail

      • handleFormElements

        public List<FormInput> handleFormElements​(List<FormInput> formInputs)
        Fills in form/input elements. Because we write to the singleton @code{FormInputValueHelper}, this method must be mutually exclusive. In practice, this probably has no effect because it is unlikely that someone would train the crawler using multiple browser threads.
        Overrides:
        handleFormElements in class FormHandler
        Parameters:
        formInputs - form input list.
        Returns:
      • incomplete

        private boolean incomplete​(List<FormInput> formInputs)
        Checks if the forms on the page are complete. To invoke a training pause, an element must exist in the DOM such that: 1. The element is not in the map of visited elements. 2. The element is visible
        Returns:
        true if there are input elements in the DOM that the trainer has not seen yet.
      • pauseAndTrainModal

        private void pauseAndTrainModal​(List<FormInput> formInputs)
        Pauses the crawl for manual form input. After the user is finished, input formInputs are stored and shared across handlers in the static map TrainingFormHandler.formInputs.
        Parameters:
        formInputs - The input elements in the current DOM.
      • getInputValue

        private InputValue getInputValue​(FormInput input)
        Generates the InputValue for the form input by inspecting the current value of the corresponding WebElement on the DOM.
        Returns:
        The current InputValue for the element on the DOM.