Example usage for org.openqa.selenium.chrome ChromeOptions ChromeOptions

List of usage examples for org.openqa.selenium.chrome ChromeOptions ChromeOptions

Introduction

In this page you can find the example usage for org.openqa.selenium.chrome ChromeOptions ChromeOptions.

Prototype

public ChromeOptions() 

Source Link

Usage

From source file:org.auraframework.test.util.WebDriverUtil.java

License:Apache License

public static synchronized ChromeOptions addChromeOptions(DesiredCapabilities capabilities,
        Dimension windowSize) {//from w w  w . j  av  a  2s  .  c o  m
    ChromeOptions options = new ChromeOptions();
    List<String> arguments = Lists.newArrayList();
    arguments.add("--ignore-gpu-blacklist");
    if (windowSize != null) {
        arguments.add("window-size=" + windowSize.width + ',' + windowSize.height);
    }
    options.addArguments(arguments);
    // To remove message "You are using an unsupported command-line flag: --ignore-certificate-errors.
    // Stability and security will suffer."
    // Add an argument 'test-type'
    options.addArguments("test-type");
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    return options;
}

From source file:org.cerberus.engine.execution.impl.SeleniumServerService.java

License:Open Source License

/**
 * Set DesiredCapabilities//from   w ww.  ja  va 2 s.co  m
 * @param tCExecution
 * @return
 * @throws CerberusException
 */
private DesiredCapabilities setCapabilities(TestCaseExecution tCExecution) throws CerberusException {
    /**
     * Instanciate DesiredCapabilities
     */
    DesiredCapabilities caps = new DesiredCapabilities();
    if (!StringUtil.isNullOrEmpty(tCExecution.getBrowser())) {
        caps = this.setCapabilityBrowser(caps, tCExecution.getBrowser(), tCExecution);
    }
    /**
     * Feed DesiredCapabilities with values get from Robot
     */
    if (!StringUtil.isNullOrEmpty(tCExecution.getPlatform())) {
        caps.setCapability("platform", tCExecution.getPlatform());
    }
    if (!StringUtil.isNullOrEmpty(tCExecution.getVersion())) {
        caps.setCapability("version", tCExecution.getVersion());
    }

    /**
     * Loop on RobotCapabilities to feed DesiredCapabilities
     */
    List<RobotCapability> additionalCapabilities = tCExecution.getCapabilities();
    if (additionalCapabilities != null) {
        for (RobotCapability additionalCapability : additionalCapabilities) {
            caps.setCapability(additionalCapability.getCapability(), additionalCapability.getValue());
        }
    }

    /**
     * if application is a mobile one, then set the "app" capability to the
     * application binary path
     */
    if (tCExecution.getApplicationObj().getType().equalsIgnoreCase("APK")
            || tCExecution.getApplicationObj().getType().equalsIgnoreCase("IPA")) {
        // Set the app capability with the application path
        if (tCExecution.isManualURL()) {
            caps.setCapability("app", tCExecution.getMyHost());
        } else {
            caps.setCapability("app", tCExecution.getCountryEnvironmentParameters().getIp());
        }
    }

    /**
     * Add custom capabilities
     */
    // Maximize windows for chrome browser
    if ("chrome".equals(caps.getBrowserName())) {
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--kiosk");
        caps.setCapability(ChromeOptions.CAPABILITY, options);
    }

    return caps;
}

From source file:org.codehaus.mojo.screenshot.ScreenshotMojo.java

License:Apache License

public void execute() throws MojoExecutionException {
    System.setProperty("webdriver.chrome.driver", chromeDriverPath);
    webDriverMap = new HashMap<String, WebDriver>();
    final DesiredCapabilities firefoxCapabilities = DesiredCapabilities.firefox();
    firefoxCapabilities.setJavascriptEnabled(true);
    WebDriver firefoxDriver = new FirefoxDriver(firefoxCapabilities);
    firefoxDriver.manage().window().maximize();
    webDriverMap.put("firefox", firefoxDriver);
    final DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
    ieCapabilities.setJavascriptEnabled(true);
    WebDriver ieDriver = new InternetExplorerDriver(ieCapabilities);
    ieDriver.manage().window().maximize();
    webDriverMap.put("ie", ieDriver);
    final ChromeOptions chromeOptions = new ChromeOptions();
    WebDriver chromeDriver = new ChromeDriver(chromeOptions);
    chromeDriver.manage().window().maximize();
    webDriverMap.put("chrome", chromeDriver);
    WebDriver smallChromeDriver = new ChromeDriver(chromeOptions);
    smallChromeDriver.manage().window().setSize(new Dimension(400, 800));
    webDriverMap.put("chrome-small", smallChromeDriver);
    if (this.inDirectory.exists() && this.inDirectory.isDirectory()) {
        final List<String> includes = new ArrayList<String>();
        includes.add("**/*.html");

        final List<String> excludes = new ArrayList<String>();
        excludes.add("**/archive/**");

        final DirectoryWalker dw = new DirectoryWalker();
        dw.setBaseDir(this.inDirectory);
        dw.setIncludes(includes);//ww w.  ja  va  2  s  .  co m
        dw.setExcludes(excludes);

        dw.addDirectoryWalkListener(new ScreenshotDirectoryWalker());
        dw.scan();
    } else {
        getLog().debug("No wireframes in that folder");
    }
}

From source file:org.core.ChromeBenchmark.java

License:Open Source License

@Override
protected WebDriver getWebDriver(TestCase test) {
    ChromeOptions options = new ChromeOptions();

    options.addArguments(/*from w ww .  j  a v  a2  s  . c  o m*/
            "user-agent=Mozilla/5.0 (Linux; U; Android 2.1-update1; de-de; HTC Desire 1.19.161.5 Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17");

    if (test.getProxy() != null && !test.getProxy().equals("")) {
        if (test.getProxy().endsWith(".pac") || test.getProxy().endsWith(".js"))
            options.addArguments("proxy-pac-url=" + test.getProxy());
        else
            options.addArguments("proxy-server=" + test.getProxy());
    }

    return new ChromeDriver(options);
}

From source file:org.eclipse.che.selenium.core.SeleniumWebDriver.java

License:Open Source License

private RemoteWebDriver doCreateDriver(URL webDriverUrl) {
    DesiredCapabilities capability;//ww w.  ja v a 2 s.  com

    switch (browser) {
    case GOOGLE_CHROME:
        LoggingPreferences loggingPreferences = new LoggingPreferences();
        loggingPreferences.enable(LogType.PERFORMANCE, Level.ALL);
        loggingPreferences.enable(LogType.BROWSER, Level.ALL);

        ChromeOptions options = new ChromeOptions();
        options.addArguments("--no-sandbox");
        options.addArguments("--dns-prefetch-disable");
        options.addArguments("--ignore-certificate-errors");

        // set parameters required for automatic download capability
        Map<String, Object> chromePrefs = new HashMap<>();
        chromePrefs.put("download.default_directory", downloadDir);
        chromePrefs.put("download.prompt_for_download", false);
        chromePrefs.put("download.directory_upgrade", true);
        chromePrefs.put("safebrowsing.enabled", true);
        chromePrefs.put("profile.default_content_settings.popups", 0);
        chromePrefs.put("plugins.plugins_disabled", "['Chrome PDF Viewer']");
        options.setExperimentalOption("prefs", chromePrefs);

        capability = DesiredCapabilities.chrome();
        capability.setCapability(ChromeOptions.CAPABILITY, options);
        capability.setCapability(CapabilityType.LOGGING_PREFS, loggingPreferences);
        capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        break;

    default:
        capability = DesiredCapabilities.firefox();
        capability.setCapability("dom.max_script_run_time", 240);
        capability.setCapability("dom.max_chrome_script_run_time", 240);
    }

    RemoteWebDriver driver = new RemoteWebDriver(webDriverUrl, capability);
    if (driver.getErrorHandler().isIncludeServerErrors()
            && driver.getCapabilities().getCapability("message") != null) {
        String errorMessage = format("Web driver creation error occurred: %s",
                driver.getCapabilities().getCapability("message"));
        LOG.error(errorMessage);
        throw new RuntimeException(errorMessage);
    }

    driver.manage().window().setSize(new Dimension(1920, 1080));

    return driver;
}

From source file:org.jboss.arquillian.drone.webdriver.factory.CapabilitiesChromeOptionsMapperTest.java

License:Apache License

@Test
public void testParseChromeOptions() throws IOException {
    ChromeOptions chromeOptions = new ChromeOptions();
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

    String arguments = "--my-cool --arguments";
    desiredCapabilities.setCapability("chromeArguments", arguments);

    String extensions = "src/test/resources/files/my-file src/test/resources/files/cool-file src/test/resources/files/cool-extension";
    desiredCapabilities.setCapability("chromeExtensions", extensions);

    String encodedExtensions = "src/test/resources/files/cool-file src/test/resources/files/cool-extension";
    desiredCapabilities.setCapability("chromeEncodedExtensions", encodedExtensions);

    String experimentalOptionJson = "{\"perfLoggingPrefs\": {\n"
            + "\"traceCategories\": \",blink.console,disabled-by-default-devtools.timeline,benchmark\"\n"
            + " }, \"prefs\": {\"download.default_directory\": \"/usr/local/path/to/download/directory\"} }";
    desiredCapabilities.setCapability("chromeExperimentalOption", experimentalOptionJson);

    CapabilitiesOptionsMapper.mapCapabilities(chromeOptions, desiredCapabilities, "chrome");

    ChromeOptions expectedChromeOptions = new ChromeOptions();
    expectedChromeOptions.addArguments(arguments.split(" "));
    for (String path : extensions.split(" ")) {
        expectedChromeOptions.addExtensions(new File(path));
    }/*from   w  ww.  j ava2  s  . co m*/
    expectedChromeOptions.addEncodedExtensions(encodedExtensions.split(" "));

    Map<String, Map<String, String>> dicts = handleJson(experimentalOptionJson);
    for (String param : dicts.keySet()) {
        expectedChromeOptions.setExperimentalOption(param, dicts.get(param));
    }

    Assert.assertEquals(expectedChromeOptions, chromeOptions);
    Assert.assertEquals(expectedChromeOptions.toJson(), chromeOptions.toJson());
}

From source file:org.jitsi.meet.test.ConferenceFixture.java

License:Apache License

/**
 * Starts a <tt>WebDriver</tt> instance using default settings.
 * @param browser the browser type./*from ww w  . java2 s.co m*/
 * @param participant the participant we are creating a driver for.
 * @return the <tt>WebDriver</tt> instance.
 */
private static WebDriver startDriverInstance(BrowserType browser, Participant participant) {
    // by default we load chrome, but we can load safari or firefox
    if (browser == BrowserType.firefox) {
        String browserBinary = System.getProperty(BROWSER_FF_BINARY_NAME_PROP);
        if (browserBinary != null && browserBinary.trim().length() > 0) {
            File binaryFile = new File(browserBinary);
            if (binaryFile.exists())
                System.setProperty("webdriver.firefox.bin", browserBinary);
        }

        FirefoxProfile profile = new FirefoxProfile();
        profile.setPreference("media.navigator.permission.disabled", true);
        // Enables tcp in firefox, disabled by default in 44
        profile.setPreference("media.peerconnection.ice.tcp", true);
        profile.setAcceptUntrustedCertificates(true);

        profile.setPreference("webdriver.log.file", FailureListener.createLogsFolder() + "/firefox-js-console-"
                + getParticipantName(participant) + ".log");

        System.setProperty("webdriver.firefox.logfile", FailureListener.createLogsFolder() + "/firefox-console-"
                + getParticipantName(participant) + ".log");

        return new FirefoxDriver(profile);
    } else if (browser == BrowserType.safari) {
        return new SafariDriver();
    } else if (browser == BrowserType.ie) {
        DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
        caps.setCapability("ignoreZoomSetting", true);
        System.setProperty("webdriver.ie.driver.silent", "true");

        return new InternetExplorerDriver(caps);
    } else {
        System.setProperty("webdriver.chrome.verboseLogging", "true");
        System.setProperty("webdriver.chrome.logfile", FailureListener.createLogsFolder() + "/chrome-console-"
                + getParticipantName(participant) + ".log");

        DesiredCapabilities caps = DesiredCapabilities.chrome();
        LoggingPreferences logPrefs = new LoggingPreferences();
        logPrefs.enable(LogType.BROWSER, Level.ALL);
        caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);

        final ChromeOptions ops = new ChromeOptions();
        ops.addArguments("use-fake-ui-for-media-stream");
        ops.addArguments("use-fake-device-for-media-stream");
        ops.addArguments("disable-extensions");
        ops.addArguments("disable-plugins");
        ops.addArguments("mute-audio");

        String disProp = System.getProperty(DISABLE_NOSANBOX_PARAM);
        if (disProp == null && !Boolean.parseBoolean(disProp)) {
            ops.addArguments("no-sandbox");
            ops.addArguments("disable-setuid-sandbox");
        }

        // starting version 46 we see crashes of chrome GPU process when
        // running in headless mode
        // which leaves the browser opened and selenium hang forever.
        // There are reports that in older version crashes like that will
        // fallback to software graphics, we try to disable gpu for now
        ops.addArguments("disable-gpu");

        String browserProp;
        if (participant == Participant.secondParticipantDriver)
            browserProp = BROWSER_CHROME_BINARY_SECOND_NAME_PROP;
        else
            browserProp = BROWSER_CHROME_BINARY_OWNER_NAME_PROP;

        String browserBinary = System.getProperty(browserProp);
        if (browserBinary != null && browserBinary.trim().length() > 0) {
            File binaryFile = new File(browserBinary);
            if (binaryFile.exists())
                ops.setBinary(binaryFile);
        }

        if (fakeStreamAudioFName != null) {
            ops.addArguments("use-file-for-fake-audio-capture=" + fakeStreamAudioFName);
        }

        if (fakeStreamVideoFName != null) {
            ops.addArguments("use-file-for-fake-video-capture=" + fakeStreamVideoFName);
        }

        //ops.addArguments("vmodule=\"*media/*=3,*turn*=3\"");
        ops.addArguments("enable-logging");
        ops.addArguments("vmodule=*=3");

        caps.setCapability(ChromeOptions.CAPABILITY, ops);

        try {
            final ExecutorService pool = Executors.newFixedThreadPool(1);
            // we will retry four times for 1 minute to obtain
            // the chrome driver, on headless environments chrome hangs
            // and we wait forever
            for (int i = 0; i < 2; i++) {
                Future<ChromeDriver> future = null;
                try {
                    future = pool.submit(new Callable<ChromeDriver>() {
                        @Override
                        public ChromeDriver call() throws Exception {
                            long start = System.currentTimeMillis();
                            ChromeDriver resDr = new ChromeDriver(ops);
                            System.err.println("ChromeDriver created for:"
                                    + (System.currentTimeMillis() - start) + " ms.");
                            return resDr;
                        }
                    });

                    ChromeDriver res = future.get(2, TimeUnit.MINUTES);
                    if (res != null)
                        return res;
                } catch (TimeoutException te) {
                    // cancel current task
                    if (future != null)
                        future.cancel(true);

                    System.err.println("Timeout waiting for "
                            + "chrome instance! We will retry now, this was our" + "attempt " + i);
                }

            }
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }

        // keep the old code
        System.err.println("Just create ChromeDriver, may hang!");
        return new ChromeDriver(ops);
    }
}

From source file:org.jitsi.meet.test.web.WebParticipantFactory.java

License:Apache License

/**
 * Starts a <tt>WebDriver</tt> instance using default settings.
 * @param options the options to use when creating the driver.
 * @return the <tt>WebDriver</tt> instance.
 *///from   w  w  w . j  a  v a2s  . c  o  m
private WebDriver startWebDriver(WebParticipantOptions options) {
    ParticipantType participantType = options.getParticipantType();
    String version = options.getVersion();
    File browserBinaryAPath = getFile(options, options.getBinary());

    boolean isRemote = options.isRemote();

    // by default we load chrome, but we can load safari or firefox
    if (participantType.isFirefox()) {
        FirefoxDriverManager.getInstance().setup();

        if (browserBinaryAPath != null && (browserBinaryAPath.exists() || isRemote)) {
            System.setProperty("webdriver.firefox.bin", browserBinaryAPath.getAbsolutePath());
        }

        FirefoxProfile profile = new FirefoxProfile();
        profile.setPreference("media.navigator.permission.disabled", true);
        // Enables tcp in firefox, disabled by default in 44
        profile.setPreference("media.peerconnection.ice.tcp", true);
        profile.setPreference("media.navigator.streams.fake", true);
        profile.setAcceptUntrustedCertificates(true);

        profile.setPreference("webdriver.log.file",
                FailureListener.createLogsFolder() + "/firefox-js-console-" + options.getName() + ".log");

        System.setProperty("webdriver.firefox.logfile",
                FailureListener.createLogsFolder() + "/firefox-console-" + options.getName() + ".log");

        if (isRemote) {
            FirefoxOptions ffOptions = new FirefoxOptions();
            ffOptions.setProfile(profile);

            if (version != null && version.length() > 0) {
                ffOptions.setCapability(CapabilityType.VERSION, version);
            }

            return new RemoteWebDriver(options.getRemoteDriverAddress(), ffOptions);
        }

        return new FirefoxDriver(new FirefoxOptions().setProfile(profile));
    } else if (participantType == ParticipantType.safari) {
        // You must enable the 'Allow Remote Automation' option in
        // Safari's Develop menu to control Safari via WebDriver.
        // In Safari->Preferences->Websites, select Camera,
        // and select Allow for "When visiting other websites"
        if (isRemote) {
            return new RemoteWebDriver(options.getRemoteDriverAddress(), new SafariOptions());
        }
        return new SafariDriver();
    } else if (participantType == ParticipantType.edge) {
        InternetExplorerDriverManager.getInstance().setup();

        InternetExplorerOptions ieOptions = new InternetExplorerOptions();
        ieOptions.ignoreZoomSettings();

        System.setProperty("webdriver.ie.driver.silent", "true");

        return new InternetExplorerDriver(ieOptions);
    } else {
        ChromeDriverManager.getInstance().setup();

        System.setProperty("webdriver.chrome.verboseLogging", "true");
        System.setProperty("webdriver.chrome.logfile",
                FailureListener.createLogsFolder() + "/chrome-console-" + options.getName() + ".log");

        LoggingPreferences logPrefs = new LoggingPreferences();
        logPrefs.enable(LogType.BROWSER, Level.ALL);

        final ChromeOptions ops = new ChromeOptions();
        ops.addArguments("use-fake-ui-for-media-stream");
        ops.addArguments("use-fake-device-for-media-stream");
        ops.addArguments("disable-plugins");
        ops.addArguments("mute-audio");
        ops.addArguments("disable-infobars");
        // Since chrome v66 there are new autoplay policies, which broke
        // shared video tests, disable no-user-gesture to make it work
        ops.addArguments("autoplay-policy=no-user-gesture-required");

        if (options.getChromeExtensionId() != null) {
            try {
                ops.addExtensions(downloadExtension(options.getChromeExtensionId()));
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        ops.addArguments("auto-select-desktop-capture-source=Entire screen");

        ops.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);

        if (options.isChromeSandboxDisabled()) {
            ops.addArguments("no-sandbox");
            ops.addArguments("disable-setuid-sandbox");
        }

        if (options.isHeadless()) {
            ops.addArguments("headless");
            ops.addArguments("window-size=1200x600");
        }

        // starting version 46 we see crashes of chrome GPU process when
        // running in headless mode
        // which leaves the browser opened and selenium hang forever.
        // There are reports that in older version crashes like that will
        // fallback to software graphics, we try to disable gpu for now
        ops.addArguments("disable-gpu");

        if (browserBinaryAPath != null && (browserBinaryAPath.exists() || isRemote)) {
            ops.setBinary(browserBinaryAPath.getAbsolutePath());
        }

        File uplinkFile = getFile(options, options.getUplink());
        if (uplinkFile != null) {
            ops.addArguments("uplink=" + uplinkFile.getAbsolutePath());
        }

        File downlinkFile = getFile(options, options.getDownlink());
        if (downlinkFile != null) {
            ops.addArguments("downlink=" + downlinkFile.getAbsolutePath());
        }

        String profileDirectory = options.getProfileDirectory();
        if (profileDirectory != null && profileDirectory != "") {
            ops.addArguments("user-data-dir=" + profileDirectory);
        }

        File fakeStreamAudioFile = getFile(options, options.getFakeStreamAudioFile());
        if (fakeStreamAudioFile != null) {
            ops.addArguments("use-file-for-fake-audio-capture=" + fakeStreamAudioFile.getAbsolutePath());
        }

        File fakeStreamVideoFile = getFile(options, options.getFakeStreamVideoFile());
        if (fakeStreamVideoFile != null) {
            ops.addArguments("use-file-for-fake-video-capture=" + fakeStreamVideoFile.getAbsolutePath());
        }

        //ops.addArguments("vmodule=\"*media/*=3,*turn*=3\"");
        ops.addArguments("enable-logging");
        ops.addArguments("vmodule=*=3");

        if (isRemote) {
            if (version != null && version.length() > 0) {
                ops.setCapability(CapabilityType.VERSION, version);
            }

            return new RemoteWebDriver(options.getRemoteDriverAddress(), ops);
        }

        try {
            final ExecutorService pool = Executors.newFixedThreadPool(1);
            // we will retry four times for 1 minute to obtain
            // the chrome driver, on headless environments chrome hangs
            // and we wait forever
            for (int i = 0; i < 2; i++) {
                Future<ChromeDriver> future = null;
                try {
                    future = pool.submit(() -> {
                        long start = System.currentTimeMillis();
                        ChromeDriver resDr = new ChromeDriver(ops);
                        TestUtils.print(
                                "ChromeDriver created for:" + (System.currentTimeMillis() - start) + " ms.");
                        return resDr;
                    });

                    ChromeDriver res = future.get(2, TimeUnit.MINUTES);
                    if (res != null)
                        return res;
                } catch (TimeoutException te) {
                    // cancel current task
                    future.cancel(true);

                    TestUtils.print("Timeout waiting for " + "chrome instance! We will retry now, this was our"
                            + "attempt " + i);
                }

            }
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }

        // keep the old code
        TestUtils.print("Just create ChromeDriver, may hang!");
        return new ChromeDriver(ops);
    }
}

From source file:org.kitodo.selenium.testframework.Browser.java

License:Open Source License

private static void provideChromeDriver() throws IOException {
    String driverFileName = "chromedriver";
    if (SystemUtils.IS_OS_WINDOWS) {
        driverFileName = driverFileName.concat(".exe");
    }//  ww w  .  j  a  v a2s .  c o m
    File driverFile = new File(DRIVER_DIR + driverFileName);

    if (!driverFile.exists()) {
        logger.debug(driverFile.getAbsolutePath() + " does not exist, providing chrome driver now");
        WebDriverProvider.provideChromeDriver(CHROME_DRIVER_VERSION, DOWNLOAD_DIR, DRIVER_DIR);
    }

    ChromeDriverService service = new ChromeDriverService.Builder().usingDriverExecutable(driverFile)
            .usingAnyFreePort().build();

    Map<String, Object> chromePrefs = new HashMap<>();
    chromePrefs.put("download.default_directory", DOWNLOAD_DIR);
    chromePrefs.put("download.prompt_for_download", false);
    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOption("prefs", chromePrefs);

    webDriver = new ChromeDriver(service, options);
}

From source file:org.kurento.room.test.RoomTest.java

License:Open Source License

protected WebDriver newWebDriver() {
    ChromeOptions options = new ChromeOptions();

    // This flag avoids granting camera/microphone
    options.addArguments("--use-fake-ui-for-media-stream");

    // This flag makes using a synthetic video (green with spinner) in
    // WebRTC instead of real media from camera/microphone
    options.addArguments("--use-fake-device-for-media-stream");

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());

    ExecutorService webExec = Executors.newFixedThreadPool(1);
    BrowserInit initThread = new BrowserInit(capabilities);
    webExec.execute(initThread);/*from   w  w  w  .  ja v a  2  s.  c  om*/
    webExec.shutdown();
    try {
        if (!webExec.awaitTermination(DRIVER_INIT_THREAD_TIMEOUT, TimeUnit.SECONDS)) {
            log.warn("Webdriver init thread timed-out after {}s, will be interrupted",
                    DRIVER_INIT_THREAD_TIMEOUT);
            initThread.interrupt();
            initThread.join(DRIVER_INIT_THREAD_JOIN);
        }
    } catch (InterruptedException e) {
        log.error("Interrupted exception", e);
        fail(e.getMessage());
    }

    return initThread.getBrowser();
}