当前位置: 首页>>代码示例>>Java>>正文


Java BrowserType类代码示例

本文整理汇总了Java中com.crawljax.browser.EmbeddedBrowser.BrowserType的典型用法代码示例。如果您正苦于以下问题:Java BrowserType类的具体用法?Java BrowserType怎么用?Java BrowserType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BrowserType类属于com.crawljax.browser.EmbeddedBrowser包,在下文中一共展示了BrowserType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: chromeProxyConfig

import com.crawljax.browser.EmbeddedBrowser.BrowserType; //导入依赖的package包/类
@Test
public void chromeProxyConfig() {
	assumeThat(System.getProperty("webdriver.chrome.driver"), is(notNullValue()));
	CrawlSession crawl =
	        new BaseCrawler(Resource.newClassPathResource("/site"),
	                "simplelink/simplelink.html") {
		        @Override
		        public CrawljaxConfigurationBuilder newCrawlConfigurationBuilder() {
			        CrawljaxConfigurationBuilder builder =
			                super.newCrawlConfigurationBuilder();
			        builder.setBrowserConfig(new BrowserConfiguration(BrowserType.CHROME));
			        return builder;
		        }
	        }.crawl();
	assertThat(crawl.getStateFlowGraph(), hasStates(2));
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:17,代码来源:ChromeProxyConfig.java

示例2: setupForConsumers

import com.crawljax.browser.EmbeddedBrowser.BrowserType; //导入依赖的package包/类
private void setupForConsumers(int consumers) {
	executor = Executors.newFixedThreadPool(consumers + 2);
	CrawljaxConfiguration config =
	        CrawljaxConfiguration
	                .builderFor("http://example.com")
	                .addPlugin(postCrawlPlugin)
	                .setBrowserConfig(
	                        new BrowserConfiguration(BrowserType.FIREFOX, consumers))
	                .build();

	candidateActions =
	        new UnfiredCandidateActions(config.getBrowserConfig(), graphProvider,
	                new MetricRegistry());

	consumersDoneLatch = new ExitNotifier(config.getMaximumStates());

	when(consumerFactory.get()).thenReturn(new CrawlTaskConsumer(candidateActions,
	        consumersDoneLatch, crawler));

	crawlSessionProvider = new CrawlSessionProvider(graph, config, new MetricRegistry());

	Plugins plugins = new Plugins(config, new MetricRegistry());
	controller = new CrawlController(executor, consumerFactory, config, consumersDoneLatch,
	        crawlSessionProvider, plugins);

}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:27,代码来源:CrawlControllerTest.java

示例3: whenRemoteBrowserNeedsUrl

import com.crawljax.browser.EmbeddedBrowser.BrowserType; //导入依赖的package包/类
private void whenRemoteBrowserNeedsUrl() {
	if (specifiesBrowser() && getSpecifiedBrowser() == BrowserType.REMOTE) {
		checkArgument(!isNullOrEmpty(getSpecifiedRemoteBrowser()),
		        "When using remote browser the URL cannot be null");
	}

}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:8,代码来源:ParameterInterpeter.java

示例4: getSpecifiedBrowser

import com.crawljax.browser.EmbeddedBrowser.BrowserType; //导入依赖的package包/类
BrowserType getSpecifiedBrowser() {
	String browser = parameters.getOptionValue(BROWSER);
	System.out.println(browser);
	for (BrowserType b : BrowserType.values()) {
		if (b.name().equalsIgnoreCase(browser)) {
			return b;
		}
	}
	throw new IllegalArgumentException("Unrecognized browser: '" + browser
	        + "'. Available browsers are: " + availableBrowsers());
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:12,代码来源:ParameterInterpeter.java

示例5: whenRemoteBrowserSpecifiedWithUrlItResumes

import com.crawljax.browser.EmbeddedBrowser.BrowserType; //导入依赖的package包/类
@Test
public void whenRemoteBrowserSpecifiedWithUrlItResumes() {
	JarRunner runner =
	        new JarRunner(defaultArgsPlus("-b " + BrowserType.REMOTE.name()
	                + " -" + ParameterInterpeter.BROWSER_REMOTE_URL + " localhost:9000"));
	assertThat(streams.getErrorOutput(), isEmptyString());
	BrowserConfiguration config = runner.getConfig().getBrowserConfig();
	assertThat(config.getBrowsertype(), is(BrowserType.REMOTE));
	assertThat(config.getRemoteHubUrl(), is("localhost:9000"));

}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:12,代码来源:JarRunnerTest.java

示例6: testCustomBrowserConfig

import com.crawljax.browser.EmbeddedBrowser.BrowserType; //导入依赖的package包/类
@Test
public void testCustomBrowserConfig() {
	BrowserConfiguration config =
	        configForArgs("-p 123 -b " + BrowserType.CHROME).getBrowserConfig();
	assertThat(config.getNumberOfBrowsers(), is(123));
	assertThat(config.getBrowsertype(), is(BrowserType.CHROME));
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:8,代码来源:JarRunnerTest.java

示例7: BrowserConfiguration

import com.crawljax.browser.EmbeddedBrowser.BrowserType; //导入依赖的package包/类
/**
 * @param browsertype
 *            The browser you'd like to use.
 * @param numberOfBrowsers
 *            The number of browsers you'd like to use. They will be started as soon as the
 *            crawl starts.
 * @param builder
 *            a custom {@link WebDriverBrowserBuilder}.
 */
public BrowserConfiguration(BrowserType browsertype, int numberOfBrowsers,
        Provider<EmbeddedBrowser> builder) {
	Preconditions.checkArgument(numberOfBrowsers > 0,
	        "Number of browsers should be 1 or more");
	Preconditions.checkNotNull(browsertype);
	Preconditions.checkNotNull(builder);

	this.browsertype = browsertype;
	this.numberOfBrowsers = numberOfBrowsers;
	this.browserBuilder = builder;
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:21,代码来源:BrowserConfiguration.java

示例8: configureCrawljax

import com.crawljax.browser.EmbeddedBrowser.BrowserType; //导入依赖的package包/类
/**
 * Set Crawljax configuration here
 * @param builder
 */
private void configureCrawljax(CrawljaxConfigurationBuilder builder) {
	
	CSSCatcher cssCatcher = new CSSCatcher();
	cssCatcher.setOutputFolder(outputFolder + "css/");
	
	builder.addPlugin(new CrawlOverview());
	builder.addPlugin(cssCatcher);
	
	//builder.addPlugin(new LoginPlugin());
	
	//builder.crawlRules().clickDefaultElements();
	//builder.crawlRules().dontClick("input").withAttribute("value", "I don't recognize");
	//builder.crawlRules().click("input").withAttribute("type", "submit");
	//builder.crawlRules().dontClick("a").underXPath("//*[@id='pageFooter']");
	//builder.crawlRules().dontClick("a").underXPath("//*[@id='content']/div/div[2]");
	//System.getProperties().setProperty("webdriver.chrome.driver", "chromedriver.exe");
	//builder.setBrowserConfig(new BrowserConfiguration(BrowserType.CHROME, 2));
	builder.setBrowserConfig(new BrowserConfiguration(BrowserType.FIREFOX, 1));
	builder.crawlRules().insertRandomDataInInputForms(false);
	builder.crawlRules().clickElementsInRandomOrder(false);
	builder.crawlRules().crawlFrames(true);
	builder.crawlRules().dontClick("*");
	
	//com.crawljax.browser.WebDriverBackedEmbeddedBrowser s;
	
	builder.setOutputDirectory(new File(outputFolder + "/crawljax"));
					
	builder.setMaximumDepth(1);
	builder.setMaximumStates(2);
	
	builder.crawlRules().waitAfterReloadUrl(20, TimeUnit.MILLISECONDS);
	builder.crawlRules().waitAfterEvent(200, TimeUnit.MILLISECONDS);
	
}
 
开发者ID:dmazinanian,项目名称:css-analyser,代码行数:39,代码来源:Crawler.java

示例9: main

import com.crawljax.browser.EmbeddedBrowser.BrowserType; //导入依赖的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

示例10: readConfig

import com.crawljax.browser.EmbeddedBrowser.BrowserType; //导入依赖的package包/类
private CrawljaxConfiguration readConfig(String urlValue, String outputDir) {
	CrawljaxConfigurationBuilder builder = CrawljaxConfiguration.builderFor(urlValue);

	builder.setOutputDirectory(new File(outputDir));

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

	int browsers = 1;
	if (options.specifiesParallelBrowsers()) {
		browsers = options.getSpecifiedNumberOfBrowsers();
	}
	if (browser == BrowserType.REMOTE) {
		String remoteUrl = options.getSpecifiedRemoteBrowser();
		builder.setBrowserConfig(BrowserConfiguration.remoteConfig(browsers, remoteUrl));
	} else {
		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());

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

	return builder.build();
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:46,代码来源:JarRunner.java

示例11: availableBrowsers

import com.crawljax.browser.EmbeddedBrowser.BrowserType; //导入依赖的package包/类
private String availableBrowsers() {
	return Joiner.on(", ").join(BrowserType.values());
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:4,代码来源:ParameterInterpeter.java

示例12: whenBrowserSpecifiedItIsConfigured

import com.crawljax.browser.EmbeddedBrowser.BrowserType; //导入依赖的package包/类
@Test
public void whenBrowserSpecifiedItIsConfigured() {
	new JarRunner(defaultArgsPlus("-b " + BrowserType.CHROME.name()));
	assertThat(streams.getErrorOutput(), isEmptyString());
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:6,代码来源:JarRunnerTest.java

示例13: whenRemoteBrowserSpecifiedWithoutUrlItStops

import com.crawljax.browser.EmbeddedBrowser.BrowserType; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void whenRemoteBrowserSpecifiedWithoutUrlItStops() {
	new JarRunner(defaultArgsPlus("-b " + BrowserType.REMOTE.name()));
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:5,代码来源:JarRunnerTest.java

示例14: getBrowsertype

import com.crawljax.browser.EmbeddedBrowser.BrowserType; //导入依赖的package包/类
public BrowserType getBrowsertype() {
	return browsertype;
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:4,代码来源:BrowserConfiguration.java

示例15: getBrowserConfiguration

import com.crawljax.browser.EmbeddedBrowser.BrowserType; //导入依赖的package包/类
@Override
BrowserConfiguration getBrowserConfiguration() {
	return new BrowserConfiguration(BrowserType.FIREFOX, 1);
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:5,代码来源:LargeFirefoxTest.java


注:本文中的com.crawljax.browser.EmbeddedBrowser.BrowserType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。