Crawljax supports the use of plugins which can be used to extend Crawljax and use your own tests and tools.
Plugins can be added via the addPlugin() method in CrawljaxConfiguration.
The main interface is Plugin which is implemented by the different types of plugins. To write a plugin you should implement one of the following plugins types.
Type | Called | Example |
---|---|---|
PreCrawlingPlugin | Before the crawling | Login |
OnNewStatePlugin | When a new state is found while crawling | Create Screenshots |
OnUrlLoadPlugin | After the initial URL is (re)loaded | Reset backend state |
PreStateCrawlingPlugin | Before a new state is crawled | Logging the candidate elements |
PostCrawlingPlugin | After the crawling | Generating tests |
Create a new class.
public class MyTestPlugin implements OnNewStatePlugin { @Override public void onNewState(CrawlSession session) { String name = session.getCurrentState().getName(); String url = session.getBrowser().getCurrentUrl(); System.out.println("New State: " + name + "; url: " + url); } }
Add this plugin to your Crawljax configuration.
CrawljaxConfigurationBuilder builder = CrawljaxConfiguration.builderFor(URL); builder.addPlugin(new MyTestPlugin());