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


Java DesiredCapabilities.phantomjs方法代碼示例

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


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

示例1: createPhantomJSDriver

import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
private static WebDriver createPhantomJSDriver(String driverPath) {

		DesiredCapabilities desiredCapabilities = DesiredCapabilities.phantomjs();
		desiredCapabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, driverPath);
		desiredCapabilities.setCapability(CapabilityType.ELEMENT_SCROLL_BEHAVIOR, true);
		desiredCapabilities.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
		desiredCapabilities.setCapability(CapabilityType.ENABLE_PROFILING_CAPABILITY, true);
		desiredCapabilities.setCapability(CapabilityType.HAS_NATIVE_EVENTS, true);

		desiredCapabilities.setJavascriptEnabled(true);

		ArrayList<String> cliArgs = new ArrayList<String>();
		cliArgs.add("--web-security=true");
		cliArgs.add("--ignore-ssl-errors=true");
		desiredCapabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgs);

		return new PhantomJSDriver(desiredCapabilities);
	}
 
開發者ID:entelgy-brasil,項目名稱:zucchini,代碼行數:19,代碼來源:SeleniumDriver.java

示例2: createWebDriver

import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
private WebDriver createWebDriver(final Consumer<DesiredCapabilities> desiredCapabilities) {

		String hostName = GhostDriverService.get().getHostName();

		DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
		if (desiredCapabilities != null) {
			desiredCapabilities.accept(capabilities);
		}
		try {
			WebDriver driver = new RemoteWebDriver(new URL("http://localhost:" + GhostDriverService.get().getLocalPort() + "/"), capabilities);
			driver.manage().window().setSize(new Dimension(1920, 1080));
			return driver;
		} catch (MalformedURLException e) {
			throw new IllegalStateException("Wrong hostName '" + hostName + "', possibly GhostDriverService::start not called ", e);
		}
	}
 
開發者ID:xtf-cz,項目名稱:xtf,代碼行數:17,代碼來源:WebDriverService.java

示例3: PhantomJSFetcher

import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
private PhantomJSFetcher(String phantomJsBinaryPath, int timeout, boolean loadImages, String userAgent, Collection<Cookie> cookies) {
    System.setProperty("phantomjs.binary.path", phantomJsBinaryPath);
    DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
    capabilities.setCapability("phantomjs.page.settings.resourceTimeout", timeout);
    capabilities.setCapability("phantomjs.page.settings.loadImages", loadImages);
    capabilities.setCapability("phantomjs.page.settings.userAgent", userAgent);
    this.webDriver = new PhantomJSDriver(capabilities);
    this.userAgent = userAgent;
    this.cookies = cookies;
}
 
開發者ID:ZhangJiupeng,項目名稱:Gospy,代碼行數:11,代碼來源:PhantomJSFetcher.java

示例4: PhantomJSProcessor

import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
private PhantomJSProcessor(String phantomJsBinaryPath, int timeout, boolean loadImages, String userAgent, Extractor<WebDriver, ?> handler, TaskFilter filter) {
    System.setProperty("phantomjs.binary.path", phantomJsBinaryPath);
    DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
    capabilities.setCapability("phantomjs.page.settings.resourceTimeout", timeout);
    capabilities.setCapability("phantomjs.page.settings.loadImages", loadImages);
    capabilities.setCapability("phantomjs.page.settings.userAgent", userAgent);
    this.webDriver = new PhantomJSDriver(capabilities);
    this.handler = handler;
    this.filter = filter;
}
 
開發者ID:ZhangJiupeng,項目名稱:Gospy,代碼行數:11,代碼來源:PhantomJSProcessor.java

示例5: prepareDriver

import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
/**
 * Create the driver instance
 */
@Override
protected void prepareDriver() throws Exception {
	if (!isLocalTest()) {
		capability = DesiredCapabilities.phantomjs();
	}
	super.prepareDriver();
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:11,代碼來源:TAbstractSeleniumITCase.java

示例6: SeleniumGridParallelITCase

import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
public SeleniumGridParallelITCase() {
	// Add phantomjs in test
	super.repeatedCapabilities = new DesiredCapabilities[] { DesiredCapabilities.phantomjs(), DesiredCapabilities.phantomjs() };
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:5,代碼來源:SeleniumGridParallelITCase.java

示例7: SeleniumGridSequentialITCase

import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
public SeleniumGridSequentialITCase() {
	// Add phantomjs in test
	super.repeatedCapabilities = new DesiredCapabilities[] { DesiredCapabilities.phantomjs(), DesiredCapabilities.phantomjs() };
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:5,代碼來源:SeleniumGridSequentialITCase.java

示例8: createPhantomJsDesiredCapabilities

import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
public DesiredCapabilities createPhantomJsDesiredCapabilities(SiteConfig siteConfig, DriverConfig driverConfig) {
    DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();

    capabilities.setJavascriptEnabled(true);

    return capabilities;
}
 
開發者ID:brucezee,項目名稱:jspider,代碼行數:8,代碼來源:WebDriverFactory.java


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