Package com.crawljax.fragmentation
Class FragmentationPlugin
- java.lang.Object
-
- com.crawljax.fragmentation.FragmentationPlugin
-
- All Implemented Interfaces:
OnNewStatePlugin,OnRevisitStatePlugin,Plugin,PostCrawlingPlugin
public class FragmentationPlugin extends Object implements OnNewStatePlugin, OnRevisitStatePlugin, PostCrawlingPlugin
-
-
Field Summary
Fields Modifier and Type Field Description static booleanCOMPARE_FASTstatic booleanDISABLE_STATE_COMPprivate static booleanexportFragmentsprivate static org.slf4j.LoggerLOG
-
Constructor Summary
Constructors Constructor Description FragmentationPlugin()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddFragments(StateVertex newState, FragmentManager manager)private static voidexportFragDom(HybridStateVertexImpl state, File outputDir)static voidfragmentState(StateVertex newState, FragmentManager manager, EmbeddedBrowser browser, File outputDir, boolean exportDom)Main function that gets called everytime a new state is discovered.static voidloadFragmentState(StateVertex fragState, FragmentManager manager, Document dom, BufferedImage screenshot)Loads a statevertex in an offline setting using a previously fragmented and recorded DOM.voidonNewState(CrawlerContext context, StateVertex newState)Method that is called when a new state is found.voidonRevisitState(CrawlerContext context, StateVertex currentState)Method that is called every time a state is revisited by Crawljax.voidpostCrawling(CrawlSession session, ExitNotifier.ExitStatus exitReason)Exports the comparison results during crawling.static voidwriteCrawlPath(CrawlSession session, CrawlPath crawlPath, int id)
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
COMPARE_FAST
public static final boolean COMPARE_FAST
- See Also:
- Constant Field Values
-
DISABLE_STATE_COMP
public static final boolean DISABLE_STATE_COMP
- See Also:
- Constant Field Values
-
exportFragments
private static final boolean exportFragments
- See Also:
- Constant Field Values
-
-
Method Detail
-
loadFragmentState
public static void loadFragmentState(StateVertex fragState, FragmentManager manager, Document dom, BufferedImage screenshot)
Loads a statevertex in an offline setting using a previously fragmented and recorded DOM. This is useful to determine the similarity between a previously recorded state and the current browser state in a regression test scenario.- Parameters:
fragState-manager-dom-screenshot-
-
fragmentState
public static void fragmentState(StateVertex newState, FragmentManager manager, EmbeddedBrowser browser, File outputDir, boolean exportDom)
Main function that gets called everytime a new state is discovered. Uses VIPS to perform fragmentation and calls fragment manager to analyze fragments- Parameters:
newState-manager-browser-outputDir-exportDom-
-
addFragments
public static void addFragments(StateVertex newState, FragmentManager manager)
-
exportFragDom
private static void exportFragDom(HybridStateVertexImpl state, File outputDir)
-
writeCrawlPath
public static void writeCrawlPath(CrawlSession session, CrawlPath crawlPath, int id)
-
onNewState
public void onNewState(CrawlerContext context, StateVertex newState)
Description copied from interface:OnNewStatePluginMethod that is called when a new state is found. When this method is called the state is already added to theStateFlowGraph.This method can be called from multiple threads with different
CrawlerContext- Specified by:
onNewStatein interfaceOnNewStatePlugin- Parameters:
context- the current context.newState- The new state. Equivalent toCrawlerContext.getCurrentState().
-
onRevisitState
public void onRevisitState(CrawlerContext context, StateVertex currentState)
Description copied from interface:OnRevisitStatePluginMethod that is called every time a state is revisited by Crawljax. Warning: changing the state can influence crawljax, it is not a copy.This method can be called from multiple threads with different
CrawlerContext- Specified by:
onRevisitStatein interfaceOnRevisitStatePlugin- Parameters:
context- the crawlSessioncurrentState- the state revisited
-
postCrawling
public void postCrawling(CrawlSession session, ExitNotifier.ExitStatus exitReason)
Exports the comparison results during crawling. Also preserves the information regarding extracted fragments from states.- Specified by:
postCrawlingin interfacePostCrawlingPlugin- Parameters:
session- the crawl session.exitReason- TheExitNotifier.ExitStatusCrawljax stopped.
-
-