當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。