/**
   * Run this method to start the crawl.
   *
   * @throws IOException when the output folder cannot be created or emptied.
   */
  public static void main(String[] args) throws IOException {
    CrawljaxConfigurationBuilder builder = CrawljaxConfiguration.builderFor(URL);
    builder.crawlRules().insertRandomDataInInputForms(false);

    // We are going to use the WebScarab proxy plugin
    WebScarabProxyPlugin proxyPlugin = new WebScarabProxyPlugin();
    // Provide the JS file to be inserted
    proxyPlugin.addPlugin(new JSInjectorProxyAddon(new File("foo.js")));
    builder.addPlugin(proxyPlugin);

    // Configure the proxy to use the port 8084 (you can change this of course)
    builder.setProxyConfig(ProxyConfiguration.manualProxyOn("127.0.0.1", 8084));

    // click these elements
    builder.crawlRules().clickDefaultElements();
    builder.crawlRules().click("div").withAttribute("class", "clickable");

    builder.setMaximumStates(4);

    // Set timeouts
    builder.crawlRules().waitAfterReloadUrl(WAIT_TIME_AFTER_RELOAD, TimeUnit.MILLISECONDS);
    builder.crawlRules().waitAfterEvent(WAIT_TIME_AFTER_EVENT, TimeUnit.MILLISECONDS);

    builder.setBrowserConfig(new BrowserConfiguration(BrowserType.firefox, 1));

    CrawljaxRunner crawljax = new CrawljaxRunner(builder.build());
    crawljax.call();
  }
 public void stop() {
   if (crawljax != null) {
     crawljax.stop();
   }
   stopServer();
 }
 public void start() {
   crawljax = new CrawljaxRunner(getCrawljaxBuilder());
   crawljax.call();
   stopServer();
 }