import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import com.crawljax.browser.EmbeddedBrowser.BrowserType;
import com.crawljax.condition.NotXPathCondition;
import com.crawljax.core.CrawljaxRunner;
import com.crawljax.core.configuration.BrowserConfiguration;
import com.crawljax.core.configuration.CrawljaxConfiguration;
import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder;
import com.crawljax.core.configuration.Form;
import com.crawljax.core.configuration.InputSpecification;
/**
* Example of running Crawljax with the CrawlOverview plugin on a single-page web app. The crawl
* will produce output using the {@link CrawlOverview} plugin.
*/
class app {
private static final long WAIT_TIME_AFTER_EVENT = 200;
private static final long WAIT_TIME_AFTER_RELOAD = 20;
private static final String URL = "http://demo.crawljax.com";
/**
* 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);
// click these elements
builder.crawlRules().clickDefaultElements();
builder.crawlRules().click("div");
builder.setMaximumStates(10);
builder.setMaximumDepth(3);
builder.crawlRules().clickElementsInRandomOrder(true);
// Set timeouts
builder.crawlRules().waitAfterReloadUrl(WAIT_TIME_AFTER_RELOAD, TimeUnit.MILLISECONDS);
builder.crawlRules().waitAfterEvent(WAIT_TIME_AFTER_EVENT, TimeUnit.MILLISECONDS);
// We want to use two browsers simultaneously.
builder.setBrowserConfig(new BrowserConfiguration(BrowserType.FIREFOX, 1));
CrawljaxRunner crawljax;
crawljax = new CrawljaxRunner(builder.build());
crawljax.call();
}
private static InputSpecification getInputSpecification() {
InputSpecification input = new InputSpecification();
Form contactForm = new Form();
contactForm.field("male").setValues(true, false);
contactForm.field("female").setValues(false, true);
contactForm.field("name").setValues("Bob", "Alice", "John");
contactForm.field("phone").setValues("1234567890", "1234888888", "");
contactForm.field("mobile").setValues("123", "3214321421");
contactForm.field("type").setValues("Student", "Teacher");
contactForm.field("active").setValues(true); input.setValuesInForm(contactForm).beforeClickElement("button").withText("Save");
return input;
}
}
这是crawljax的代码,它在我运行时给出错误,错误是
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableList
at com.crawljax.core.configuration.CrawljaxConfiguration$CrawljaxConfigurationBuilder.<init>(CrawljaxConfiguration.java:28)
at com.crawljax.core.configuration.CrawljaxConfiguration$CrawljaxConfigurationBuilder.<init>(CrawljaxConfiguration.java:26)
at com.crawljax.core.configuration.CrawljaxConfiguration.builderFor(CrawljaxConfiguration.java:217)
at app.main(NewClass.java:34)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.ImmutableList
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 4 more