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


Java DesiredCapabilities.chrome方法代码示例

本文整理汇总了Java中org.openqa.selenium.remote.DesiredCapabilities.chrome方法的典型用法代码示例。如果您正苦于以下问题:Java DesiredCapabilities.chrome方法的具体用法?Java DesiredCapabilities.chrome怎么用?Java DesiredCapabilities.chrome使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openqa.selenium.remote.DesiredCapabilities的用法示例。


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

示例1: createDriver

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
@Override
public WebDriver createDriver(DesiredCapabilities capabilities) {
    Map<String, Object> preferences = new Hashtable<>();
    preferences.put("profile.default_content_settings.popups", 0);
    preferences.put("download.prompt_for_download", "false");
    String downloadsPath = System.getProperty("user.home") + "/Downloads";
    preferences.put("download.default_directory", loadSystemPropertyOrDefault("fileDownloadPath", downloadsPath));
    preferences.put("plugins.plugins_disabled", new String[]{
            "Adobe Flash Player", "Chrome PDF Viewer"});
    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOption("prefs", preferences);

    capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    return new ChromeDriver(capabilities);
}
 
开发者ID:alfa-laboratory,项目名称:akita-testing-template,代码行数:18,代码来源:AkitaChromeDriverProvider.java

示例2: newDriverForTest

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
private WebDriver newDriverForTest() {
    ChromeOptions theOptions = new ChromeOptions();
    theOptions.addArguments("headless");
    theOptions.addArguments("disable-gpu");

    LoggingPreferences theLoggingPreferences = new LoggingPreferences();
    theLoggingPreferences.enable(LogType.BROWSER, Level.ALL);
    theOptions.setCapability(CapabilityType.LOGGING_PREFS, theLoggingPreferences);

    DesiredCapabilities theCapabilities = DesiredCapabilities.chrome();
    theCapabilities.setCapability(ChromeOptions.CAPABILITY, theOptions);

    return new RemoteWebDriver(DRIVERSERVICE.getUrl(), theCapabilities);
}
 
开发者ID:mirkosertic,项目名称:Bytecoder,代码行数:15,代码来源:BytecoderUnitTestRunner.java

示例3: createDriver

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
/**
 * Создание instance google chrome эмулирующего работу на мобильном устройстве (по умолчанию nexus 5)
 * Мобильное устройство может быть задано через системные переменные
 *
 * @param capabilities настройки Chrome браузера
 * @return возвращает новый instance Chrome драйера
 */

@Override
public WebDriver createDriver(DesiredCapabilities capabilities) {
    log.info("---------------run CustomMobileDriver---------------------");
    String mobileDeviceName = loadSystemPropertyOrDefault("device", "Nexus 5");
    Map<String, String> mobileEmulation = new HashMap<>();
    mobileEmulation.put("deviceName", mobileDeviceName);

    Map<String, Object> chromeOptions = new HashMap<>();
    chromeOptions.put("mobileEmulation", mobileEmulation);

    DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();
    desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
    desiredCapabilities.setBrowserName(desiredCapabilities.chrome().getBrowserName());
    return new ChromeDriver(desiredCapabilities);
}
 
开发者ID:alfa-laboratory,项目名称:akita,代码行数:24,代码来源:MobileChrome.java

示例4: testDriver

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
@Test
public void testDriver() throws IOException {
    WebDriver driver = new RemoteWebDriver(toUrl("http://localhost:9515"), DesiredCapabilities.chrome());
    driver.get(URL2);

    String response = driver.getPageSource();
    Document doc = Jsoup.connect(URL2).ignoreContentType(true).get();
    Elements scriptTags = doc.select("body");

    // get All functions


    try {
        String result = (String) engine.eval(response);
    } catch (ScriptException e) {
        e.printStackTrace();
    }

    log.info("PageSource " + response);

    driver.quit();
}
 
开发者ID:robevansuk,项目名称:delay-repay-bot,代码行数:23,代码来源:PhantomJSTest.java

示例5: getWebDriver

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
@Override
public WebDriver getWebDriver()
{
	System.setProperty("webdriver.chrome.driver", "src/test/resources/chromedriver.2.27");
       DesiredCapabilities capabilities = DesiredCapabilities.chrome();
       return new ChromeDriver(capabilities);
}
 
开发者ID:5hawnknight,项目名称:functional-programming-selenium-examples,代码行数:8,代码来源:Chrome.java

示例6: generateGoogleChromeDriver

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
/**
 * Generates a chrome webdriver.
 *
 * @param headlessMode
 *            Enable headless mode ?
 * @return
 *         A chrome webdriver
 * @throws TechnicalException
 *             if an error occured when Webdriver setExecutable to true.
 */
private WebDriver generateGoogleChromeDriver(boolean headlessMode) throws TechnicalException {
    final String pathWebdriver = DriverFactory.getPath(Driver.CHROME);
    if (!new File(pathWebdriver).setExecutable(true)) {
        throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE));
    }
    logger.info("Generating Chrome driver ({}) ...", pathWebdriver);

    System.setProperty(Driver.CHROME.getDriverName(), pathWebdriver);

    final ChromeOptions chromeOptions = new ChromeOptions();
    final DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
    capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);

    setLoggingLevel(capabilities);

    if (Context.isHeadless()) {
        chromeOptions.addArguments("--headless");
    }

    // Proxy configuration
    if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
        capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
    }

    setChromeOptions(capabilities, chromeOptions);

    String withWhitelistedIps = Context.getWebdriversProperties("withWhitelistedIps");
    if (withWhitelistedIps != null && !"".equals(withWhitelistedIps)) {
        ChromeDriverService service = new ChromeDriverService.Builder().withWhitelistedIps(withWhitelistedIps).withVerbose(false).build();
        return new ChromeDriver(service, capabilities);
    } else {
        return new ChromeDriver(capabilities);
    }
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:46,代码来源:DriverFactory.java

示例7: createBrowserSession

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
private static WebDriver createBrowserSession() throws MalformedURLException {
	DesiredCapabilities capabilities = DesiredCapabilities.chrome();
	capabilities.setJavascriptEnabled(true);
	LoggingPreferences logPreferences = new LoggingPreferences();
	logPreferences.enable(LogType.BROWSER, Level.ALL);
	capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPreferences);
	return new RemoteWebDriver(
			new URL("http://" + runtime.getContainer("selenium-chrome").getIp() + ":4444/wd/hub"),
			capabilities
	);
}
 
开发者ID:swissquote,项目名称:carnotzet,代码行数:12,代码来源:ExamplesTest.java

示例8: capabilitiesAndroid

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
private static DesiredCapabilities capabilitiesAndroid() {
	DesiredCapabilities capabilities = DesiredCapabilities.chrome();

	Map<String, String> mobileEmulation = new HashMap<>();
	mobileEmulation.put("deviceName", "Google Nexus 5");

	Map<String, Object> chromeOptions = new HashMap<>();
	chromeOptions.put("mobileEmulation", mobileEmulation);
	capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

	return capabilities;
}
 
开发者ID:sergueik,项目名称:SWET,代码行数:13,代码来源:BrowserDriver.java

示例9: capabilitiesiPhone

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
private static DesiredCapabilities capabilitiesiPhone() {
	DesiredCapabilities capabilities = DesiredCapabilities.chrome();

	Map<String, String> mobileEmulation = new HashMap<>();
	mobileEmulation.put("deviceName", "Apple iPhone 6");

	Map<String, Object> chromeOptions = new HashMap<>();
	chromeOptions.put("mobileEmulation", mobileEmulation);
	capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

	return capabilities;
}
 
开发者ID:sergueik,项目名称:SWET,代码行数:13,代码来源:BrowserDriver.java

示例10: capabilitiesiPad

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
private static DesiredCapabilities capabilitiesiPad() {
	DesiredCapabilities capabilities = DesiredCapabilities.chrome();

	Map<String, String> mobileEmulation = new HashMap<>();
	mobileEmulation.put("deviceName", "Apple iPad");

	Map<String, Object> chromeOptions = new HashMap<>();
	chromeOptions.put("mobileEmulation", mobileEmulation);
	capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

	return capabilities;
}
 
开发者ID:sergueik,项目名称:SWET,代码行数:13,代码来源:BrowserDriver.java

示例11: DebateFetcher

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
public DebateFetcher(String chromeDriverFile)
        throws IOException
{
    service = new ChromeDriverService.Builder()
            .usingDriverExecutable(
                    new File(chromeDriverFile))
            .usingAnyFreePort()
            .withEnvironment(ImmutableMap.of("DISPLAY", ":20")).build();
    service.start();

    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    driver = new RemoteWebDriver(service.getUrl(), capabilities);
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:14,代码来源:DebateFetcher.java

示例12: initChromeDriver

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
private WebDriver initChromeDriver(String appURL) {
	System.out.println("Launching google chrome with new profile..");
	DesiredCapabilities handlSSLErr = DesiredCapabilities.chrome ()    ;   
			handlSSLErr.setCapability (CapabilityType.ACCEPT_SSL_CERTS, true);
	ChromeDriver driver = new ChromeDriver(handlSSLErr);
	driver.manage().window().maximize();
	driver.navigate().to(appURL);
	return new WebDriverProxy().protect(driver);
}
 
开发者ID:3pillarlabs,项目名称:AutomationFrameworkTPG,代码行数:10,代码来源:DriverProperties.java

示例13: getChromeDriver

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
public static WebDriver getChromeDriver()
{
       String path = "src/test/resources/chromedriver";
	System.setProperty("webdriver.chrome.driver", path);

	DesiredCapabilities capabilities = DesiredCapabilities.chrome();
       capabilities.setCapability("networkConnectionEnabled", true);
       capabilities.setCapability("browserConnectionEnabled", true);

       return new ChromeDriver(capabilities);
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:12,代码来源:SeleniumTestUtilities.java

示例14: chrome

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
public Builder chrome() {
    this.browserCaps = DesiredCapabilities.chrome();

    ChromeOptions options = new ChromeOptions();
    options.addArguments("'--start-maximized", "--window-size=1360,1020");
    this.browserCaps.setCapability(ChromeOptions.CAPABILITY, options);
    this.browserCaps.setCapability("enableVNC", true);

    return this;
}
 
开发者ID:italia,项目名称:daf-cacher,代码行数:11,代码来源:Browser.java

示例15: setUp

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
@BeforeTest
public void setUp() throws MalformedURLException {
    driver = new RemoteWebDriver(new URL("http://localhost:9515"), DesiredCapabilities.chrome());
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
}
 
开发者ID:extsoft,项目名称:jcat,代码行数:7,代码来源:Base.java


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