Java 类org.openqa.selenium.chrome.ChromeDriverService.Builder 实例源码

项目:de.lgohlke.selenium-webdriver    文件:ChromeDriverServiceFactory.java   
public ChromeDriverService createService(String... args) {
    Preconditions.checkArgument(args.length % 2 == 0, "arguments should be pairs");

    Map<String, String> environment = new HashMap<>();
    for (int i = 1; i < args.length; i += 2) {
        environment.put(args[i - 1], args[i]);
    }

    handleDISPLAYonLinux(environment);

    ChromeDriverService service = new Builder()
            .usingDriverExecutable(locationStrategy.findExecutable())
            .withVerbose(log.isDebugEnabled())
            .withEnvironment(environment)
            .usingAnyFreePort()
            .build();

    LoggingOutputStream loggingOutputStream = new LoggingOutputStream(log, LogLevel.INFO);
    service.sendOutputTo(loggingOutputStream);

    return service;
}
项目:domui    文件:WebDriverFactory.java   
private static WebDriver allocateChromeInstance(BrowserModel model, Locale lang) throws IOException {
    DesiredCapabilities dc;
    switch(model) {
        default:
            throw new IllegalStateException("Unsupported browser type " + model.getCode() + " for local execution");

        case CHROME:
            dc = getChromeCapabilities(lang);
            break;

        case CHROME_HEADLESS:
            dc = getChromeHeadlessCapabilities(lang);
            break;
    }

    TestProperties tp = TUtilTestProperties.getTestProperties();
    String chromeBinariesLocation = tp.getProperty("webdriver.chrome.driver", "/usr/bin/google-chrome");
    System.setProperty("webdriver.chromedriver", chromeBinariesLocation);
    dc.setCapability("chrome.binary", chromeBinariesLocation);

    //-- Set the XDG_CONFIG_HOME envvar; this is used by fontconfig as one of its locations
    File dir = createFontConfigFile();
    Map<String, String> env = new HashMap<>();
    env.put("XDG_CONFIG_HOME", dir.getParentFile().getAbsolutePath());

    Builder builder = new Builder();
    builder.usingAnyFreePort();
    builder.withEnvironment(env);
    ChromeDriverService service = builder.build();
    MyChromeDriver chromeDriver = new MyChromeDriver(service, dc);

    chromeDriver.manage().window().setSize(new Dimension(1280, 1024));

    String browserName = chromeDriver.getCapabilities().getBrowserName();
    String version = chromeDriver.getCapabilities().getVersion();
    System.out.println("wd: allocated " + browserName + " " + version);

    return chromeDriver;
}
项目:minium    文件:ChromeDriverServiceProperties.java   
@Override
protected DriverService createDriverService() {
    Builder builder = new ChromeDriverService.Builder();
    if (port != null) builder.usingPort(port);
    if (driverExecutable != null) builder.usingDriverExecutable(driverExecutable);
    if (environment != null) builder.withEnvironment(environment);
    if (logFile != null) builder.withLogFile(logFile);
    if (verbose != null) builder.withVerbose(verbose);
    if (silent != null) builder.withSilent(silent);
    return builder.build();
}