Package com.crawljax.core.configuration.CrawljaxConfiguration

Examples of com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder


  /**
   * retrieve / build the CrawljaxConfiguration for the given arguments.
   */
  protected CrawljaxConfiguration getCrawljaxConfiguration() {

    CrawljaxConfigurationBuilder builder =
            CrawljaxConfiguration.builderFor(WEB_SERVER.getSiteUrl());
    builder.crawlRules().waitAfterEvent(getTimeOutAfterEvent(), TimeUnit.MILLISECONDS);
    builder.crawlRules()
            .waitAfterReloadUrl(getTimeOutAfterReloadUrl(), TimeUnit.MILLISECONDS);
    builder.setMaximumDepth(3);
    builder.crawlRules().clickOnce(true);

    builder.setBrowserConfig(getBrowserConfiguration());

    addCrawlElements(builder);

    builder.crawlRules().setInputSpec(getInputSpecification());

    addCrawlConditions(builder);
    addOracleComparators(builder);
    addInvariants(builder);
    addWaitConditions(builder);
    addPlugins(builder);

    return builder.build();
  }
View Full Code Here


  @Test
  public void testHiddenElementsSiteCrawl() throws Exception {
    CrawlSession crawl = new BaseCrawler("hidden-elements-site") {
      @Override
      public CrawljaxConfigurationBuilder newCrawlConfigurationBuilder() {
        CrawljaxConfigurationBuilder builder =
                super.newCrawlConfigurationBuilder();
        builder.crawlRules().crawlHiddenAnchors(true);
        return builder;
      }
    }.crawl();

    StateFlowGraph stateFlowGraph = crawl.getStateFlowGraph();
View Full Code Here

    }
  }

  @Test
  public void testExtract() throws InterruptedException, CrawljaxException {
    CrawljaxConfigurationBuilder builder =
            CrawljaxConfiguration.builderFor(DEMO_SITE_SERVER.getSiteUrl().toExternalForm());
    builder.crawlRules().click("a");
    builder.crawlRules().clickOnce(true);
    CrawljaxConfiguration config = builder.build();

    CandidateElementExtractor extractor = newElementExtractor(config);
    browser.goToUrl(DEMO_SITE_SERVER.getSiteUrl());
    List<CandidateElement> candidates = extractor.extract(DUMMY_STATE);
View Full Code Here

    return extractor;
  }

  @Test
  public void testExtractExclude() throws Exception {
    CrawljaxConfigurationBuilder builder =
            CrawljaxConfiguration.builderFor(DEMO_SITE_SERVER.getSiteUrl().toExternalForm());
    builder.crawlRules().click("a");
    builder.crawlRules().dontClick("div").withAttribute("id", "menubar");
    builder.crawlRules().clickOnce(true);
    CrawljaxConfiguration config = builder.build();

    CandidateElementExtractor extractor = newElementExtractor(config);
    browser.goToUrl(DEMO_SITE_SERVER.getSiteUrl());

    List<CandidateElement> candidates = extractor.extract(DUMMY_STATE);
View Full Code Here

  @Test
  public void testExtractIframeContents() throws Exception {
    RunWithWebServer server = new RunWithWebServer("/site");
    server.before();
    CrawljaxConfigurationBuilder builder = CrawljaxConfiguration
            .builderFor(server.getSiteUrl().toExternalForm() + "iframe/");
    builder.crawlRules().click("a");
    CrawljaxConfiguration config = builder.build();

    CandidateElementExtractor extractor = newElementExtractor(config);
    browser.goToUrl(new URL(server.getSiteUrl().toExternalForm() + "iframe/"));
    List<CandidateElement> candidates = extractor.extract(DUMMY_STATE);
View Full Code Here

  }

  @Test
  public void whenNoFollowExternalUrlDoNotFollow() throws IOException {
    CrawljaxConfigurationBuilder builder =
            CrawljaxConfiguration.builderFor("http://example.com");
    builder.crawlRules().click("a");
    CrawljaxConfiguration config = builder.build();
    CandidateElementExtractor extractor = newElementExtractor(config);

    List<CandidateElement> extract = extractFromTestFile(extractor);

    assertThat(config.getCrawlRules().followExternalLinks(), is(false));
View Full Code Here

    assertThat(extract, hasSize(2));
  }

  @Test
  public void whenFollowExternalUrlDoFollow() throws IOException {
    CrawljaxConfigurationBuilder builder =
            CrawljaxConfiguration.builderFor("http://example.com");
    builder.crawlRules().click("a");
    builder.crawlRules().followExternalLinks(true);
    CrawljaxConfiguration config = builder.build();
    CandidateElementExtractor extractor = newElementExtractor(config);

    List<CandidateElement> extract = extractFromTestFile(extractor);

    assertThat(config.getCrawlRules().followExternalLinks(), is(true));
View Full Code Here

  /**
   * Entry point
   */
  public static void main(String[] args) {
    CrawljaxConfigurationBuilder builder = CrawljaxConfiguration.builderFor(URL);
    builder.crawlRules().insertRandomDataInInputForms(false);

    builder.crawlRules().click("a");
    builder.crawlRules().click("button");

    // except these
    builder.crawlRules().dontClick("a").underXPath("//DIV[@id='guser']");
    builder.crawlRules().dontClick("a").withText("Language Tools");

    // limit the crawling scope
    builder.setMaximumStates(MAX_NUMBER_STATES);
    builder.setMaximumDepth(MAX_DEPTH);

    builder.addPlugin(new SamplePlugin());

    builder.crawlRules().setInputSpec(getInputSpecification());

    CrawljaxRunner crawljax = new CrawljaxRunner(builder.build());
    crawljax.call();
  }
View Full Code Here

    }

  }

  private CrawljaxConfiguration readConfig(String urlValue, String outputDir) {
    CrawljaxConfigurationBuilder builder = CrawljaxConfiguration.builderFor(urlValue);

    BrowserType browser = BrowserType.firefox;
    if (options.specifiesBrowser()) {
      browser = options.getSpecifiedBrowser();
    }

    int browsers = 1;
    if (options.specifiesParallelBrowsers()) {
      browsers = options.getSpecifiedNumberOfBrowsers();
    }
    builder.setBrowserConfig(new BrowserConfiguration(browser, browsers));

    if (options.specifiesDepth()) {
      builder.setMaximumDepth(options.getSpecifiedDepth());
    }

    if (options.specifiesMaxStates()) {
      builder.setMaximumStates(options.getMaxStates());
    }

    if (options.requestsCrawlHiddenAnchors()) {
      builder.crawlRules().crawlHiddenAnchors(true);
    }

    configureTimers(builder);

    builder.addPlugin(new CrawlOverview(new File(outputDir)));

    if (options.specifiesClickElements()) {
      builder.crawlRules().click(options.getSpecifiedClickElements());
    } else {
      builder.crawlRules().clickDefaultElements();
    }

    return builder.build();
  }
View Full Code Here

  @ClassRule
  public static final RunWithWebServer SERVER = new RunWithWebServer("/site");

  @Test
  public void testDontClickUnderXPath() throws Exception {
    CrawljaxConfigurationBuilder builder = SERVER.newConfigBuilder("underxpath.html");
    builder.crawlRules().click("a");
    builder.crawlRules().dontClick("a").underXPath("//A[@class=\"noClickClass\"]");
    CrawlRulesBuilder rules = builder.crawlRules();
    rules.dontClick("a").withAttribute("id", "noClickId");
    rules.dontClickChildrenOf("div").withClass("noChildrenOfClass");
    rules.dontClickChildrenOf("div").withId("noChildrenOfId");

    CrawlSession session = new CrawljaxRunner(builder.build()).call();

    assertThat(session.getStateFlowGraph(), hasStates(2));
  }
View Full Code Here

TOP

Related Classes of com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.