當前位置: 首頁>>代碼示例>>Java>>正文


Java CrawljaxConfigurationBuilder.build方法代碼示例

本文整理匯總了Java中com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder.build方法的典型用法代碼示例。如果您正苦於以下問題:Java CrawljaxConfigurationBuilder.build方法的具體用法?Java CrawljaxConfigurationBuilder.build怎麽用?Java CrawljaxConfigurationBuilder.build使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder的用法示例。


在下文中一共展示了CrawljaxConfigurationBuilder.build方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder; //導入方法依賴的package包/類
public static void main(String[] args) {

		CrawljaxConfigurationBuilder builder =
		        CrawljaxConfiguration.builderFor("http://demo.crawljax.com/");
		builder.addPlugin(new OnNewStatePlugin() {

			@Override
			public void onNewState(CrawlerContext context, StateVertex newState) {
				// This will print the DOM when a new state is detected. You should see it in your
				// console.
				LOG.info("Found a new dom! Here it is:\n{}", context.getBrowser().getStrippedDom());
			}

			@Override
			public String toString() {
				return "Our example plugin";
			}
		});
		CrawljaxRunner crawljax = new CrawljaxRunner(builder.build());
		crawljax.call();
	}
 
開發者ID:aminmf,項目名稱:crawljax,代碼行數:22,代碼來源:PluginExample.java

示例2: main

import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder; //導入方法依賴的package包/類
/**
 * Run this method to start the crawl.
 */
public static void main(String[] args) {
	CrawljaxConfigurationBuilder builder =
	        CrawljaxConfiguration.builderFor("http://demo.crawljax.com/");

	// Add the invariant that checks that the string isn't present.
	builder.crawlRules().addInvariant(
	        "Detect a string",
	        new NotRegexCondition(
	                "Invariants can be used to perform tests on the current state"));

	// This plugin will just print the error.
	builder.addPlugin(new OnInvariantViolationPlugin() {

		@Override
		public void onInvariantViolation(Invariant invariant, CrawlerContext context) {
			LOG.error("\n\n!!! Invariant {} violated !!!\n", invariant);
		}

	});

	CrawljaxRunner crawljax = new CrawljaxRunner(builder.build());
	crawljax.call();
}
 
開發者ID:aminmf,項目名稱:crawljax,代碼行數:27,代碼來源:InvariantExample.java

示例3: main

import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder; //導入方法依賴的package包/類
/**
 * 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();
}
 
開發者ID:aminmf,項目名稱:crawljax,代碼行數:26,代碼來源:Runner.java

示例4: getCrawljaxConfiguration

import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder; //導入方法依賴的package包/類
/**
 * 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();
}
 
開發者ID:aminmf,項目名稱:crawljax,代碼行數:28,代碼來源:LargeTestBase.java

示例5: testExtract

import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder; //導入方法依賴的package包/類
@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);

	assertNotNull(candidates);
	assertEquals(15, candidates.size());

}
 
開發者ID:aminmf,項目名稱:crawljax,代碼行數:17,代碼來源:CandidateElementExtractorTest.java

示例6: testExtractExclude

import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder; //導入方法依賴的package包/類
@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);

	assertNotNull(candidates);
	assertThat(candidates, hasSize(11));

}
 
開發者ID:aminmf,項目名稱:crawljax,代碼行數:19,代碼來源:CandidateElementExtractorTest.java

示例7: testExtractIframeContents

import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder; //導入方法依賴的package包/類
@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);

	for (CandidateElement e : candidates) {
		LOG.debug("candidate: " + e.getUniqueString());
	}

	server.after();

	assertNotNull(extractor);
	assertNotNull(candidates);
	assertThat(candidates, hasSize(9));

}
 
開發者ID:aminmf,項目名稱:crawljax,代碼行數:26,代碼來源:CandidateElementExtractorTest.java

示例8: testPopups

import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder; //導入方法依賴的package包/類
@Test
public void testPopups() throws CrawljaxException {
	CrawljaxConfigurationBuilder builder =
	        CrawljaxConfiguration.builderFor(WEB_SERVER.getSiteUrl().toExternalForm()
	                + "popup");
	builder.setMaximumDepth(3);
	builder.crawlRules().click("a");
	builder.crawlRules().waitAfterEvent(100, TimeUnit.MILLISECONDS);
	builder.crawlRules().waitAfterReloadUrl(100, TimeUnit.MILLISECONDS);
	CrawljaxRunner runner = new CrawljaxRunner(builder.build());
	CrawlSession session = runner.call();
	assertThat(session.getStateFlowGraph(), hasEdges(2));
	assertThat(session.getStateFlowGraph(), hasStates(3));
}
 
開發者ID:aminmf,項目名稱:crawljax,代碼行數:15,代碼來源:PopUpTest.java

示例9: testIframeExclusions

import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder; //導入方法依賴的package包/類
@Test
public void testIframeExclusions() throws CrawljaxException {
	CrawljaxConfigurationBuilder builder = setupConfig();
	builder.crawlRules().dontCrawlFrame("frame1");
	builder.crawlRules().dontCrawlFrame("sub");
	builder.crawlRules().dontCrawlFrame("frame0");
	CrawljaxConfiguration config = builder.build();
	crawljax = new CrawljaxRunner(config);
	CrawlSession session = crawljax.call();
	assertThat(session.getStateFlowGraph(), hasEdges(3));
	assertThat(session.getStateFlowGraph(), hasStates(4));
}
 
開發者ID:aminmf,項目名稱:crawljax,代碼行數:13,代碼來源:IFrameTest.java

示例10: testIFramesNotCrawled

import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder; //導入方法依賴的package包/類
@Test
public void testIFramesNotCrawled() throws CrawljaxException {
	CrawljaxConfigurationBuilder builder = setupConfig();
	builder.crawlRules().crawlFrames(false);
	crawljax = new CrawljaxRunner(builder.build());
	CrawlSession session = crawljax.call();
	assertThat(session.getStateFlowGraph(), hasEdges(3));
	assertThat(session.getStateFlowGraph(), hasStates(4));
}
 
開發者ID:aminmf,項目名稱:crawljax,代碼行數:10,代碼來源:IFrameTest.java

示例11: testIFramesWildcardsNotCrawled

import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder; //導入方法依賴的package包/類
@Test
public void testIFramesWildcardsNotCrawled() throws CrawljaxException {
	CrawljaxConfigurationBuilder builder = setupConfig();

	builder.crawlRules().dontCrawlFrame("frame%");
	builder.crawlRules().dontCrawlFrame("sub");
	crawljax = new CrawljaxRunner(builder.build());
	CrawlSession session = crawljax.call();
	assertThat(session.getStateFlowGraph(), hasEdges(3));
	assertThat(session.getStateFlowGraph(), hasStates(4));
}
 
開發者ID:aminmf,項目名稱:crawljax,代碼行數:12,代碼來源:IFrameTest.java

示例12: testCrawlingOnlySubFrames

import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder; //導入方法依賴的package包/類
@Test
public void testCrawlingOnlySubFrames() throws CrawljaxException {
	CrawljaxConfigurationBuilder builder = setupConfig();
	builder.crawlRules().dontCrawlFrame("frame1.frame10");
	crawljax = new CrawljaxRunner(builder.build());
	CrawlSession session = crawljax.call();
	assertEquals("Clickables", 12, session.getStateFlowGraph()
	        .getAllEdges().size());
	assertEquals("States", 12, session.getStateFlowGraph().getAllStates()
	        .size());
}
 
開發者ID:aminmf,項目名稱:crawljax,代碼行數:12,代碼來源:IFrameTest.java

示例13: setup

import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder; //導入方法依賴的package包/類
@Before
public void setup() {

	CrawljaxConfigurationBuilder builder = SERVER.newConfigBuilder("crawler/index.html");
	builder.addPlugin(new PreStateCrawlingPlugin() {

		@Override
		public void preStateCrawling(CrawlerContext session,
		        ImmutableList<CandidateElement> candidateElements, StateVertex state) {
			for (CandidateElement candidate : candidateElements) {
				HTMLAnchorElementImpl impl = (HTMLAnchorElementImpl) candidate.getElement();
				impl.setName("fail");
				impl.setId("eventually");
				impl.setHref("will");
				impl.setTextContent("This");
				candidate.getIdentification().setValue("/HTML[1]/BODY[1]/FAILED[1]/A[1]");
			}
		}
	});
	builder.addPlugin(new OnFireEventFailedPlugin() {
		@Override
		public void onFireEventFailed(CrawlerContext context, Eventable eventable,
		        List<Eventable> pathToFailure) {
			hits.incrementAndGet();
		}
	});

	controller = new CrawljaxRunner(builder.build());
}
 
開發者ID:aminmf,項目名稱:crawljax,代碼行數:30,代碼來源:OnFireEventFailedPluginTest.java

示例14: Start

import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder; //導入方法依賴的package包/類
public CrawljaxRunner Start(CrawljaxConfigurationBuilder builder) {
    CrawljaxRunner crawljax = new CrawljaxRunner(builder.build());
    callbacks.issueAlert("Crawljax Started: " + url);
    crawljax.call();
    callbacks.issueAlert("Crawljax Finished: " + url + " - Reason: " + crawljax.getReason());
    return crawljax;
}
 
開發者ID:malerisch,項目名稱:burp-csj,代碼行數:8,代碼來源:SetupCrawljax.java

示例15: main

import com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder; //導入方法依賴的package包/類
/**
 * 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);
	builder.setMaximumRunTime(100, TimeUnit.SECONDS);


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

	// but don't click these
	builder.crawlRules().dontClick("a").withAttribute("class", "ignore");
	builder.crawlRules().dontClick("a").underXPath("//DIV[@id='footer']");

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

	// Add a condition that this XPath doesn't exits
	builder.crawlRules().addCrawlCondition("No spans with foo as class",
	        new NotXPathCondition("//*[@class='foo']"));

	// Set some input for fields
	builder.crawlRules().setInputSpec(getInputSpecification());

	// This will generate a nice output in the output directory.
	File outFolder = new File("output");
	if (outFolder.exists()) {
		FileUtils.deleteDirectory(outFolder);
	}
	builder.setOutputDirectory(outFolder);
	builder.addPlugin(new CrawlOverview());

	// We want to use two browsers simultaneously.
	builder.setBrowserConfig(new BrowserConfiguration(BrowserType.FIREFOX, 1));

	CrawljaxRunner crawljax = new CrawljaxRunner(builder.build());
	crawljax.call();

}
 
開發者ID:aminmf,項目名稱:crawljax,代碼行數:47,代碼來源:AdvancedExample.java


注:本文中的com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder.build方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。