0
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
4

1 回答 1

0

下载 Guava 库并将其添加到您的类路径中:

番石榴库下载

于 2013-10-14T06:49:48.710 回答