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


Java EmbeddedBrowser类代码示例

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


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

示例1: configure

import com.crawljax.browser.EmbeddedBrowser; //导入依赖的package包/类
@Override
protected void configure() {
	bind(URL.class).annotatedWith(BaseUrl.class).toInstance(config.getUrl());
	bind(CrawljaxConfiguration.class).toInstance(config);
	bind(CrawlRules.class).toInstance(config.getCrawlRules());
	bind(ProxyConfiguration.class).toInstance(config.getProxyConfiguration());

	BrowserConfiguration browserConfig = config.getBrowserConfig();
	bind(BrowserConfiguration.class).toInstance(browserConfig);

	if (browserConfig.isDefaultBuilder()) {
		bind(EmbeddedBrowser.class).toProvider(WebDriverBrowserBuilder.class);
	} else {
		bind(EmbeddedBrowser.class).toProvider(
		        Providers.guicify(browserConfig.getBrowserBuilder()));
	}
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:18,代码来源:ConfigurationModule.java

示例2: getStrippedDom

import com.crawljax.browser.EmbeddedBrowser; //导入依赖的package包/类
/**
 * @param browser
 *            the current browser instance
 * @return the stripped dom using {@link OracleComparator}s.
 */
public String getStrippedDom(EmbeddedBrowser browser) {
	String newDom = browser.getStrippedDom();
	for (OracleComparator oraclePreCondition : oracleComparator) {
		// use oracle if preconditions succeeds
		if (allPreConditionsSucceed(oraclePreCondition, browser)) {

			Comparator oracle = oraclePreCondition.getOracle();
			LOGGER.debug("Using {} : {}", oracle.getClass().getSimpleName(),
			        oraclePreCondition.getId());

			// TODO dodgy code. Is the equivalence check necessary?
			boolean equivalent = oracle.isEquivalent("", newDom);
			newDom = oracle.normalize(newDom);

			if (equivalent) {
				return newDom;
			}
		}
	}
	return newDom;
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:27,代码来源:StateComparator.java

示例3: check

import com.crawljax.browser.EmbeddedBrowser; //导入依赖的package包/类
/**
 * Check invariant.
 * 
 * @param browser
 *            The browser.
 * @return Whether the condition is satisfied or <code>false</code> when it it isn't or a
 *         {@link CrawljaxException} occurs.
 */
@Override
public boolean check(EmbeddedBrowser browser) {
	String js =
	        "try{ if(" + expression + "){return '1';}else{" + "return '0';}}catch(e){"
	                + " return '0';}";
	try {
		Object object = browser.executeJavaScript(js);
		if (object == null) {
			return false;
		}
		return object.toString().equals("1");
	} catch (CrawljaxException e) {
		// Exception is caught, check failed so return false;
		return false;
	}
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:25,代码来源:JavaScriptCondition.java

示例4: getFailedConditions

import com.crawljax.browser.EmbeddedBrowser; //导入依赖的package包/类
/**
 * @param browser
 *            The browser.
 * @return a list of {@link ConditionType} where {@link Condition#check(EmbeddedBrowser)}
 *         failed.
 */
public ImmutableList<T> getFailedConditions(EmbeddedBrowser browser) {
	LOGGER.debug("Checking {} ConditionTypes", invariants.size());
	ImmutableList.Builder<T> builder = ImmutableList.builder();
	for (T invariant : invariants) {
		if (preConditionsHold(browser, invariant)) {
			Condition invariantCondition = invariant.getCondition();
			LOGGER.debug("Checking ConditionType: {}", invariant.getDescription());
			if (!invariantCondition.check(browser)) {
				LOGGER.debug("ConditionType '{}' failed", invariant.getDescription());
				builder.add(invariant);
			}
		}
	}
	return builder.build();
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:22,代码来源:ConditionTypeChecker.java

示例5: runOnBrowserCreatedPlugins

import com.crawljax.browser.EmbeddedBrowser; //导入依赖的package包/类
/**
 * Load and run the OnBrowserCreatedPlugins, this call has been made from the browserpool when a
 * new browser has been created and ready to be used by the Crawler. The PreCrawling plugins are
 * executed before these plugins are executed except that the precrawling plugins are only
 * executed on the first created browser.
 * 
 * @param newBrowser
 *            the new created browser object
 */
public void runOnBrowserCreatedPlugins(EmbeddedBrowser newBrowser) {
	LOGGER.debug("Running OnBrowserCreatedPlugins...");
	counters.get(OnBrowserCreatedPlugin.class).inc();
	for (Plugin plugin : plugins.get(OnBrowserCreatedPlugin.class)) {
		if (plugin instanceof OnBrowserCreatedPlugin) {
			LOGGER.debug("Calling plugin {}", plugin);
			try {
				((OnBrowserCreatedPlugin) plugin)
				        .onBrowserCreated(newBrowser);
			} catch (RuntimeException e) {
				reportFailingPlugin(plugin, e);
			}
		}
	}
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:25,代码来源:Plugins.java

示例6: CandidateElementExtractor

import com.crawljax.browser.EmbeddedBrowser; //导入依赖的package包/类
/**
 * Create a new CandidateElementExtractor.
 * 
 * @param checker
 *            the ExtractorManager to use for marking handled elements and retrieve the
 *            EventableConditionChecker
 * @param browser
 *            the current browser instance used in the Crawler
 * @param formHandler
 *            the form handler.
 * @param config
 *            the checker used to determine if a certain frame must be ignored.
 */
@Inject
public CandidateElementExtractor(ExtractorManager checker, @Assisted EmbeddedBrowser browser,
        FormHandler formHandler, CrawljaxConfiguration config) {
	checkedElements = checker;
	this.browser = browser;
	this.formHandler = formHandler;
	CrawlRules rules = config.getCrawlRules();
	PreCrawlConfiguration preCrawlConfig = rules.getPreCrawlConfig();
	this.excludeCrawlElements = asMultiMap(preCrawlConfig.getExcludedElements());
	this.includedCrawlElements =
	        ImmutableList
	                .<CrawlElement> builder()
	                .addAll(preCrawlConfig.getIncludedElements())
	                .addAll(rules.getInputSpecification().getCrawlElements())
	                .build();

	crawlFrames = rules.shouldCrawlFrames();
	clickOnce = rules.isClickOnce();
	ignoredFrameIdentifiers = rules.getIgnoredFrameIdentifiers();
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:34,代码来源:CandidateElementExtractor.java

示例7: testWaitConditionNoIndexOutOfBounceAfterFirstTry

import com.crawljax.browser.EmbeddedBrowser; //导入依赖的package包/类
@Test
public void testWaitConditionNoIndexOutOfBounceAfterFirstTry() {
	WaitCondition wc = new WaitCondition("tmp", WAIT_TIME_LONG, new ExpectedCondition() {
		@Override
		public boolean isSatisfied(EmbeddedBrowser browser) {
			try {
				Thread.sleep(3000);
			} catch (InterruptedException e) {
				Assert.fail(e.getMessage());
				e.printStackTrace();
			}
			return true;
		}
	});
	Assert.assertEquals("Wait timed out", WAIT_TIMEOUT, wc.testAndWait(browser));
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:17,代码来源:WaitConditionTest.java

示例8: testGetDocumentFromBrowser

import com.crawljax.browser.EmbeddedBrowser; //导入依赖的package包/类
/**
 * Test get document from browser function.
 */
@Test
public void testGetDocumentFromBrowser() throws SAXException, IOException {
	// TODO Stefan; Refactor out the direct use of FirefoxDriver
	EmbeddedBrowser browser =
	        WebDriverBackedEmbeddedBrowser.withDriver(new FirefoxDriver(),  ImmutableSortedSet.<String> of(), 200, 300);
	File index = new File(INDEX);
	String html = "";
	browser.goToUrl(new URL("file://" + index.getAbsolutePath()));
	html = browser.getStrippedDom();
	assertNotNull(html);

	Document doc = DomUtils.asDocument(html);
	assertNotNull(doc);

	browser.close();
	browser = null;

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

示例9: saveScreenshot

import com.crawljax.browser.EmbeddedBrowser; //导入依赖的package包/类
private void saveScreenshot(EmbeddedBrowser browser, String name,
        StateVertex vertex) {
	LOG.debug("Saving screenshot for state {}", name);
	File jpg = outputBuilder.newScreenShotFile(name);
	File thumb = outputBuilder.newThumbNail(name);
	try {
		byte[] screenshot = browser.getScreenShot();
		ImageWriter.writeScreenShotAndThumbnail(screenshot, jpg, thumb);
	} catch (CrawljaxException | WebDriverException e) {
		LOG.warn(
		        "Screenshots are not supported or not functioning for {}. Exception message: {}",
		        browser, e.getMessage());
		LOG.debug("Screenshot not made because {}", e.getMessage(), e);
	}
	LOG.trace("Screenshot saved");
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:17,代码来源:CrawlOverview.java

示例10: get

import com.crawljax.browser.EmbeddedBrowser; //导入依赖的package包/类
@Override
public EmbeddedBrowser get() {
    EmbeddedBrowser browser2 = null;
    if (null != CrawlPanel.Browser.getSelectedItem().toString()) {
        switch (CrawlPanel.Browser.getSelectedItem().toString()) {
            case "Firefox":
                browser2 = newFirefoxBrowser();
                break;
            case "IE":
                browser2 = newIEBrowser();
                break;
            case "Chrome":
                browser2 = newChromeBrowser();
                break;
            case "PhantomJS":
                browser2 = newPhantomBrowser();
                break;
            case "Remote":
                browser2 = newRemoteBrowser();
                break;
        }
    }
    return browser2;
}
 
开发者ID:malerisch,项目名称:burp-csj,代码行数:25,代码来源:SetupCrawljax.java

示例11: newFirefoxBrowser

import com.crawljax.browser.EmbeddedBrowser; //导入依赖的package包/类
private EmbeddedBrowser newFirefoxBrowser() {
    FirefoxProfile profile = new FirefoxProfile();
    if (CrawlPanel.manualproxy.isSelected()) {
        String host = CrawlPanel.HostProxy.getText();
        Integer port = Integer.parseInt(CrawlPanel.PortProxy.getText());
        profile.setPreference("network.proxy.type", 1);
        profile.setPreference("network.proxy.http", host);
        profile.setPreference("network.proxy.http_port", port);
        profile.setPreference("network.proxy.ssl", host);
        profile.setPreference("network.proxy.ssl_port", port);
        profile.setPreference("network.proxy.socks", host);
        profile.setPreference("network.proxy.socks_port", port);
        profile.setPreference("network.proxy.ftp", host);
        profile.setPreference("network.proxy.ftp_port", port);
    }
    
    WebDriver drivertest = new FirefoxDriver(profile);
    
    if (CrawlPanel.burpcookie.isSelected()) {
        setCookies(drivertest, "FirefoxBrowser");
    }
    
    return WebDriverBackedEmbeddedBrowser.withDriver(drivertest);
}
 
开发者ID:malerisch,项目名称:burp-csj,代码行数:25,代码来源:SetupCrawljax.java

示例12: onNewState

import com.crawljax.browser.EmbeddedBrowser; //导入依赖的package包/类
@Override
public void onNewState(CrawlerContext arg0, StateVertex arg1) {

	if ("".equals(getOutputFolder())) {
		LOGGER.warn("Output folder for CSSCather has not been set. " +
				"So there will be no output for CSSCatcher. " +
				"Use CSSCather.setOutputFolder() before CrawljaxRunner.call()");
	} 
	
	EmbeddedBrowser browser = arg0.getBrowser();

	int styleSheetLength = Integer.valueOf(browser.executeJavaScript("return document.styleSheets.length").toString());
	for (int i = 0; i < styleSheetLength; i++) {
		
		Object hrefObj = browser.executeJavaScript("return document.styleSheets[" + i + "].href");
		
		if (hrefObj != null) {
			String href = hrefObj.toString();
			cssHrefs.add(href);
			fetchAndWriteFile(href, arg1.getName(), arg1.getUrl());
		}
	}

}
 
开发者ID:dmazinanian,项目名称:css-analyser,代码行数:25,代码来源:CSSCatcher.java

示例13: FormHandler

import com.crawljax.browser.EmbeddedBrowser; //导入依赖的package包/类
@Inject
public FormHandler(@Assisted EmbeddedBrowser browser, CrawlRules config) {
	this.browser = browser;
	this.formInputValueHelper =
	        new FormInputValueHelper(config.getInputSpecification(),
	                config.isRandomInputInForms());
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:8,代码来源:FormHandler.java

示例14: allPreConditionsSucceed

import com.crawljax.browser.EmbeddedBrowser; //导入依赖的package包/类
private boolean allPreConditionsSucceed(OracleComparator oraclePreCondition,
        EmbeddedBrowser browser) {
	for (Condition preCondition : oraclePreCondition.getPreConditions()) {
		LOGGER.debug("Check precondition: " + preCondition.toString());
		if (!preCondition.check(browser)) {
			return false;
		}
	}
	return true;
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:11,代码来源:StateComparator.java

示例15: check

import com.crawljax.browser.EmbeddedBrowser; //导入依赖的package包/类
@Override
public boolean check(EmbeddedBrowser browser) {
	for (Condition condition : conditions) {
		if (!condition.check(browser)) {
			return false;
		}
	}
	return true;
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:10,代码来源:Logic.java


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