Package com.crawljax.forms
Class TrainingFormHandler
- java.lang.Object
-
- com.crawljax.forms.FormHandler
-
- com.crawljax.forms.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 Summary
Fields Modifier and Type Field Description private static org.slf4j.LoggerLOGGERprivate static StringMODAL_HTMLThe HTML to display when the crawl is paused for form input.private static Set<Identification>visitedKeeps track of the form data manually entered during training.-
Fields inherited from class com.crawljax.forms.FormHandler
browser, formInputValueHelper, RANDOM_STRING_LENGTH
-
-
Constructor Summary
Constructors Constructor Description TrainingFormHandler(EmbeddedBrowser browser, CrawlRules config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private InputValuegetInputValue(FormInput input)Generates the InputValue for the form input by inspecting the current value of the corresponding WebElement on the DOM.List<FormInput>handleFormElements(List<FormInput> formInputs)Fills in form/input elements.private booleanincomplete(List<FormInput> formInputs)Checks if the forms on the page are complete.private voidpauseAndTrainModal(List<FormInput> formInputs)Pauses the crawl for manual form input.-
Methods inherited from class com.crawljax.forms.FormHandler
getCandidateElementsForInputs, getFormInputs, resetFormInputs, resetInputElementValue, setInputElementValue
-
-
-
-
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.
-
-
Constructor Detail
-
TrainingFormHandler
@Inject public TrainingFormHandler(EmbeddedBrowser browser, CrawlRules config)
-
-
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:
handleFormElementsin classFormHandler- 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 mapTrainingFormHandler.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.
-
-