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.kurento.test.browser.Browser.java

License:Apache License

private void createChromeBrowser(DesiredCapabilities capabilities) throws MalformedURLException {

    // Chrome driver
    ChromeDriverManager.getInstance().setup();

    // Chrome options
    ChromeOptions options = new ChromeOptions();

    // Chrome extensions
    if (extensions != null && !extensions.isEmpty()) {

        for (Map<String, String> extension : extensions) {
            InputStream is = getExtensionAsInputStream(extension.values().iterator().next());
            if (is != null) {
                try {
                    File crx = File.createTempFile(extension.keySet().iterator().next(), ".crx");
                    FileUtils.copyInputStreamToFile(is, crx);
                    options.addExtensions(crx);
                } catch (Throwable t) {
                    log.error("Error loading Chrome extension {} ({} : {})", extension, t.getClass(),
                            t.getMessage());
                }/* ww w.  j a va  2 s.  c om*/
            }
        }
    }

    if (enableScreenCapture) {
        // This flag enables the screen sharing
        options.addArguments("--enable-usermedia-screen-capturing");

        String windowTitle = TEST_SCREEN_SHARE_TITLE_DEFAULT;
        if (platform != null && (platform == Platform.WINDOWS || platform == Platform.XP
                || platform == Platform.VISTA || platform == Platform.WIN8 || platform == Platform.WIN8_1)) {

            windowTitle = TEST_SCREEN_SHARE_TITLE_DEFAULT_WIN;
        }
        options.addArguments("--auto-select-desktop-capture-source="
                + getProperty(TEST_SCREEN_SHARE_TITLE_PROPERTY, windowTitle));

    } else {
        // This flag avoids grant the camera
        options.addArguments("--use-fake-ui-for-media-stream");
    }

    // This flag avoids warning in Chrome. See:
    // https://code.google.com/p/chromedriver/issues/detail?id=799
    options.addArguments("--test-type");

    if (protocol == Protocol.FILE) {
        // This flag allows reading local files in video tags
        options.addArguments("--allow-file-access-from-files");
    }

    if (!usePhysicalCam) {
        // This flag makes using a synthetic video (green with
        // spinner) in WebRTC. Or it is needed to combine with
        // use-file-for-fake-video-capture to use a file faking the
        // cam
        options.addArguments("--use-fake-device-for-media-stream=fps=30");

        if (video != null && (isLocal() || isDocker())) {

            if (!Files.exists(Paths.get(video))) {
                throw new RuntimeException("Trying to create a browser using video file " + video
                        + ", but this file doesn't exist.");
            }

            log.debug("Using video {} in browser {}", video, id);
            options.addArguments("--use-file-for-fake-video-capture=" + video);
        }
    }

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

    createDriver(capabilities, options);
}

From source file:org.kurento.test.client.BrowserClient.java

License:Open Source License

public void init() {

    Class<? extends WebDriver> driverClass = browserType.getDriverClass();

    try {//from   ww w .  j a  v a2s.  c om
        DesiredCapabilities capabilities = new DesiredCapabilities();

        if (driverClass.equals(FirefoxDriver.class)) {
            FirefoxProfile profile = new FirefoxProfile();
            // This flag avoids granting the access to the camera
            profile.setPreference("media.navigator.permission.disabled", true);

            capabilities.setCapability(FirefoxDriver.PROFILE, profile);
            capabilities.setBrowserName(DesiredCapabilities.firefox().getBrowserName());

            // Firefox extensions
            if (extensions != null && !extensions.isEmpty()) {
                for (Map<String, String> extension : extensions) {
                    InputStream is = getExtensionAsInputStream(extension.values().iterator().next());
                    if (is != null) {
                        try {
                            File xpi = File.createTempFile(extension.keySet().iterator().next(), ".xpi");
                            FileUtils.copyInputStreamToFile(is, xpi);
                            profile.addExtension(xpi);
                        } catch (Throwable t) {
                            log.error("Error loading Firefox extension {} ({} : {})", extension, t.getClass(),
                                    t.getMessage());
                        }
                    }
                }
            }

            if (scope == BrowserScope.SAUCELABS) {
                createSaucelabsDriver(capabilities);
            } else if (scope == BrowserScope.REMOTE) {
                createRemoteDriver(capabilities);
            } else {
                driver = new FirefoxDriver(profile);
            }

        } else if (driverClass.equals(ChromeDriver.class)) {
            // Chrome driver
            ChromeDriverManager.getInstance().setup();

            // Chrome options
            ChromeOptions options = new ChromeOptions();

            // Chrome extensions
            if (extensions != null && !extensions.isEmpty()) {
                for (Map<String, String> extension : extensions) {
                    InputStream is = getExtensionAsInputStream(extension.values().iterator().next());
                    if (is != null) {
                        try {
                            File crx = File.createTempFile(extension.keySet().iterator().next(), ".crx");
                            FileUtils.copyInputStreamToFile(is, crx);
                            options.addExtensions(crx);
                        } catch (Throwable t) {
                            log.error("Error loading Chrome extension {} ({} : {})", extension, t.getClass(),
                                    t.getMessage());
                        }
                    }
                }
            }

            if (enableScreenCapture) {
                // This flag enables the screen sharing
                options.addArguments("--enable-usermedia-screen-capturing");

                String windowTitle = TEST_SCREEN_SHARE_TITLE_DEFAULT;
                if (platform != null && (platform == Platform.WINDOWS || platform == Platform.XP
                        || platform == Platform.VISTA || platform == Platform.WIN8
                        || platform == Platform.WIN8_1)) {

                    windowTitle = TEST_SCREEN_SHARE_TITLE_DEFAULT_WIN;
                }
                options.addArguments("--auto-select-desktop-capture-source="
                        + getProperty(TEST_SCREEN_SHARE_TITLE_PROPERTY, windowTitle));

            } else {
                // This flag avoids grant the camera
                options.addArguments("--use-fake-ui-for-media-stream");
            }

            // This flag avoids warning in Chrome. See:
            // https://code.google.com/p/chromedriver/issues/detail?id=799
            options.addArguments("--test-type");

            if (protocol == Protocol.FILE) {
                // This flag allows reading local files in video tags
                options.addArguments("--allow-file-access-from-files");
            }

            if (!usePhysicalCam) {
                // This flag makes using a synthetic video (green with
                // spinner) in WebRTC. Or it is needed to combine with
                // use-file-for-fake-video-capture to use a file faking the
                // cam
                options.addArguments("--use-fake-device-for-media-stream");

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

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

            if (scope == BrowserScope.SAUCELABS) {
                createSaucelabsDriver(capabilities);
            } else if (scope == BrowserScope.REMOTE) {
                createRemoteDriver(capabilities);
            } else {
                driver = new ChromeDriver(options);
            }
        } else if (driverClass.equals(InternetExplorerDriver.class)) {

            if (scope == BrowserScope.SAUCELABS) {
                capabilities.setBrowserName(DesiredCapabilities.internetExplorer().getBrowserName());
                capabilities.setCapability("ignoreProtectedModeSettings", true);
                createSaucelabsDriver(capabilities);
            }

        } else if (driverClass.equals(SafariDriver.class)) {

            if (scope == BrowserScope.SAUCELABS) {
                capabilities.setBrowserName(DesiredCapabilities.safari().getBrowserName());
                createSaucelabsDriver(capabilities);
            }

        }

        // Timeouts
        changeTimeout(timeout);

        if (protocol == Protocol.FILE) {
            String clientPage = client.toString();
            File clientPageFile = new File(
                    this.getClass().getClassLoader().getResource("static" + clientPage).getFile());
            url = protocol.toString() + clientPageFile.getAbsolutePath();
        } else {
            String hostName = host != null ? host : node;
            url = protocol.toString() + hostName + ":" + serverPort + client.toString();
        }
        log.info("*** Browsing URL with WebDriver: {}", url);
        driver.get(url);

    } catch (MalformedURLException e) {
        log.error("MalformedURLException in BrowserClient.initDriver", e);
    }

    // startPing();
}

From source file:org.kurento.tutorial.magicmirror.test.MagicMirrorIT.java

License:Open Source License

@Before
public void setup() {
    ChromeOptions options = new ChromeOptions();
    // This flag avoids a warning in Chrome. See:
    // https://code.google.com/p/chromedriver/issues/detail?id=799
    options.addArguments("--test-type");
    // 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");

    driver = new ChromeDriver(options);
}

From source file:org.me.seleniumGridUI.SeleniumGridOperation.java

public static DesiredCapabilities CreateBrowserCapbility(String browser) {
    DesiredCapabilities caps = null;/*from  w w  w  . j  a  v a2 s  .c om*/
    if (browser.equalsIgnoreCase("firefox")) {
        caps = DesiredCapabilities.firefox();
    } else if (browser.equalsIgnoreCase("chrome")) {
        caps = DesiredCapabilities.chrome();
        ChromeOptions options = new ChromeOptions();
        options.addArguments("disable-popup-blocking");
        options.addArguments("disable-prompt-on-repost");
        options.addArguments("whitelist-ips");
        options.addArguments("no-first-run");
        options.addArguments("disk-cache-size=1");
        options.addArguments("media-cache-size=1");
        options.addArguments("test-type");
        caps.setCapability(ChromeOptions.CAPABILITY, options);
    } else if (browser.equalsIgnoreCase("ie")) {
        caps = DesiredCapabilities.internetExplorer();
        caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
        caps.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true);
        caps.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
        caps.setCapability(InternetExplorerDriver.ENABLE_ELEMENT_CACHE_CLEANUP, true);
        caps.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);
        caps.setCapability(InternetExplorerDriver.UNEXPECTED_ALERT_BEHAVIOR, UnexpectedAlertBehaviour.DISMISS);
    } else if (browser.equalsIgnoreCase("phantomjs")) {
        caps = DesiredCapabilities.phantomjs();
    } else if (browser.equalsIgnoreCase("safari")) {
        caps = DesiredCapabilities.safari();
    } else if (browser.equalsIgnoreCase("iphone")) {
        caps = DesiredCapabilities.iphone();
    } else if (browser.equalsIgnoreCase("ipad")) {
        caps = DesiredCapabilities.ipad();
    } else {
        caps = DesiredCapabilities.htmlUnit();
    }
    return caps;
}

From source file:org.musetest.selenium.providers.ChromeDriverProvider.java

License:Open Source License

@Override
public WebDriver getDriver(SeleniumBrowserCapabilities capabilities, MuseExecutionContext context) {
    if (getOs() != null && !(OperatingSystem.get().equals(getOs())))
        return null; // this provider is not for the current OS

    if (!capabilities.getName().equals(BrowserType.CHROME))
        return null;

    File path = getDriverLocation(context);
    if (path == null) {
        context.raiseEvent(MessageEventType.create(
                "ChromeDriverProvider would try to satisfy request for Chrome browser, but it was not configured with a path to the driver"));
        return null;
    }/*ww w. ja v  a  2 s . co  m*/

    if (!(path.exists())) {
        context.raiseEvent(MessageEventType.create(
                "ChromeDriverProvider would try to satisfy request for Chrome browser, but the configured path does not exist: "
                        + path.getAbsolutePath()));
        return null;
    }

    synchronized (ChromeDriverProvider.class) {
        ChromeOptions options = new ChromeOptions();
        if (getArguments() != null)
            options.addArguments(getArguments());

        DesiredCapabilities desired = DesiredCapabilities.chrome();
        if (capabilities.getVersion() != null && capabilities.getVersion().length() > 0)
            desired.setVersion(capabilities.getVersion());
        if (capabilities.getPlatform() != null && capabilities.getPlatform().length() > 0)
            desired.setPlatform(Platform.fromString(capabilities.getPlatform()));
        options.merge(desired);

        System.setProperty("webdriver.chrome.driver", path.getAbsolutePath());
        return new ChromeDriver(options);
    }
}

From source file:org.nuxeo.functionaltests.AbstractTest.java

License:Open Source License

@SuppressWarnings("deprecation")
protected static void initChromeDriver() throws Exception {
    if (System.getProperty(SYSPROP_CHROME_DRIVER_PATH) == null) {
        String chromeDriverDefaultPath = null;
        String chromeDriverExecutableName = CHROME_DRIVER_DEFAULT_EXECUTABLE_NAME;
        if (SystemUtils.IS_OS_LINUX) {
            chromeDriverDefaultPath = CHROME_DRIVER_DEFAULT_PATH_LINUX;
        } else if (SystemUtils.IS_OS_MAC) {
            chromeDriverDefaultPath = CHROME_DRIVER_DEFAULT_PATH_MAC;
        } else if (SystemUtils.IS_OS_WINDOWS_XP) {
            chromeDriverDefaultPath = CHROME_DRIVER_DEFAULT_PATH_WINXP;
            chromeDriverExecutableName = CHROME_DRIVER_WINDOWS_EXECUTABLE_NAME;
        } else if (SystemUtils.IS_OS_WINDOWS_VISTA) {
            chromeDriverDefaultPath = CHROME_DRIVER_DEFAULT_PATH_WINVISTA;
            chromeDriverExecutableName = CHROME_DRIVER_WINDOWS_EXECUTABLE_NAME;
        } else if (SystemUtils.IS_OS_WINDOWS) {
            // Unknown default path on other Windows OS. To be completed.
            chromeDriverExecutableName = CHROME_DRIVER_WINDOWS_EXECUTABLE_NAME;
        }/*from   w  ww. j  av a2 s . c  om*/

        if (chromeDriverDefaultPath != null && new File(chromeDriverDefaultPath).exists()) {
            log.warn(String.format("Missing property %s but found %s. Using it...", SYSPROP_CHROME_DRIVER_PATH,
                    chromeDriverDefaultPath));
            System.setProperty(SYSPROP_CHROME_DRIVER_PATH, chromeDriverDefaultPath);
        } else {
            // Can't find chromedriver in default location, check system
            // path
            File chromeDriverExecutable = findExecutableOnPath(chromeDriverExecutableName);
            if ((chromeDriverExecutable != null) && (chromeDriverExecutable.exists())) {
                log.warn(String.format("Missing property %s but found %s. Using it...",
                        SYSPROP_CHROME_DRIVER_PATH, chromeDriverExecutable.getCanonicalPath()));
                System.setProperty(SYSPROP_CHROME_DRIVER_PATH, chromeDriverExecutable.getCanonicalPath());
            } else {
                log.error(String.format(
                        "Could not find the Chrome driver looking at %s or system path."
                                + " Download it from %s and set its path with " + "the System property %s.",
                        chromeDriverDefaultPath, "http://code.google.com/p/chromedriver/downloads/list",
                        SYSPROP_CHROME_DRIVER_PATH));
            }
        }
    }
    DesiredCapabilities dc = DesiredCapabilities.chrome();
    ChromeOptions options = new ChromeOptions();
    options.addArguments(Arrays.asList("--ignore-certificate-errors"));
    Proxy proxy = startProxy();
    if (proxy != null) {
        proxy.setNoProxy("");
        dc.setCapability(CapabilityType.PROXY, proxy);
    }
    dc.setCapability(ChromeOptions.CAPABILITY, options);
    driver = new ChromeDriver(dc);
}

From source file:org.nuxeo.functionaltests.drivers.ChromeDriverProvider.java

License:Open Source License

@Override
public RemoteWebDriver init(DesiredCapabilities dc) throws Exception {
    if (System.getProperty(SYSPROP_CHROME_DRIVER_PATH) == null) {
        String chromeDriverDefaultPath = null;
        String chromeDriverExecutableName = CHROME_DRIVER_DEFAULT_EXECUTABLE_NAME;
        if (SystemUtils.IS_OS_LINUX) {
            chromeDriverDefaultPath = CHROME_DRIVER_DEFAULT_PATH_LINUX;
        } else if (SystemUtils.IS_OS_MAC) {
            chromeDriverDefaultPath = CHROME_DRIVER_DEFAULT_PATH_MAC;
        } else if (SystemUtils.IS_OS_WINDOWS_XP) {
            chromeDriverDefaultPath = CHROME_DRIVER_DEFAULT_PATH_WINXP;
            chromeDriverExecutableName = CHROME_DRIVER_WINDOWS_EXECUTABLE_NAME;
        } else if (SystemUtils.IS_OS_WINDOWS_VISTA) {
            chromeDriverDefaultPath = CHROME_DRIVER_DEFAULT_PATH_WINVISTA;
            chromeDriverExecutableName = CHROME_DRIVER_WINDOWS_EXECUTABLE_NAME;
        } else if (SystemUtils.IS_OS_WINDOWS) {
            // Unknown default path on other Windows OS. To be completed.
            chromeDriverDefaultPath = CHROME_DRIVER_DEFAULT_PATH_WINVISTA;
            chromeDriverExecutableName = CHROME_DRIVER_WINDOWS_EXECUTABLE_NAME;
        }//from   w w  w . j  a v  a 2s  .  c  o  m

        if (chromeDriverDefaultPath != null && new File(chromeDriverDefaultPath).exists()) {
            log.warn(String.format("Missing property %s but found %s. Using it...", SYSPROP_CHROME_DRIVER_PATH,
                    chromeDriverDefaultPath));
            System.setProperty(SYSPROP_CHROME_DRIVER_PATH, chromeDriverDefaultPath);
        } else {
            // Can't find chromedriver in default location, check system
            // path
            File chromeDriverExecutable = findExecutableOnPath(chromeDriverExecutableName);
            if ((chromeDriverExecutable != null) && (chromeDriverExecutable.exists())) {
                log.warn(String.format("Missing property %s but found %s. Using it...",
                        SYSPROP_CHROME_DRIVER_PATH, chromeDriverExecutable.getCanonicalPath()));
                System.setProperty(SYSPROP_CHROME_DRIVER_PATH, chromeDriverExecutable.getCanonicalPath());
            } else {
                log.error(String.format(
                        "Could not find the Chrome driver looking at %s or system path."
                                + " Download it from %s and set its path with " + "the System property %s.",
                        chromeDriverDefaultPath, "http://code.google.com/p/chromedriver/downloads/list",
                        SYSPROP_CHROME_DRIVER_PATH));
            }
        }
    }
    ChromeOptions options = new ChromeOptions();
    options.addArguments(Arrays.asList("--ignore-certificate-errors"));
    dc.setCapability(ChromeOptions.CAPABILITY, options);
    driver = new ChromeDriver(dc);
    return driver;
}

From source file:org.openqa.grid.selenium.node.ChromeMutatorTest.java

License:Apache License

@Test
public void shouldInjectBinaryIfNotSpecified() {
    ImmutableCapabilities caps = new ImmutableCapabilities(new ChromeOptions());
    ImmutableCapabilities seen = new ChromeMutator(defaultConfig).apply(caps);

    @SuppressWarnings("unchecked")
    Map<String, Object> options = (Map<String, Object>) seen.getCapability(CAPABILITY);

    assertEquals(options.get("binary"), defaultConfig.getCapability("chrome_binary"));
}

From source file:org.openqa.grid.selenium.node.ChromeMutatorTest.java

License:Apache License

@Test
public void shouldNotInjectBinaryIfSpecified() {
    ImmutableCapabilities caps = new ImmutableCapabilities(new ChromeOptions().setBinary("cheese"));
    ImmutableCapabilities seen = new ChromeMutator(defaultConfig).apply(caps);

    @SuppressWarnings("unchecked")
    Map<String, Object> options = (Map<String, Object>) seen.getCapability(CAPABILITY);

    assertEquals(options.get("binary"), "cheese");
}

From source file:org.safs.selenium.webdriver.lib.SelectBrowser.java

License:Open Source License

/**
 * /*  w  w  w .java  2 s  . com*/
 * @param browserName String, the browser name, such as "explorer"
 * @param extraParameters Map<String,Object>, can be used to pass more browser parameters, such as proxy settings.
 * @return DesiredCapabilities
 */
public static DesiredCapabilities getDesiredCapabilities(String browserName,
        Map<String, Object> extraParameters) {
    String debugmsg = StringUtils.debugmsg(false);
    DesiredCapabilities caps = null;

    if (browserName.equals(BROWSER_NAME_IE)) {
        System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_IE, "IEDriverServer.exe");
        caps = DesiredCapabilities.internetExplorer();
        caps.setCapability("nativeEvents", true);
        caps.setCapability("requireWindowFocus", true);
        //caps.setCapability("browserName", BROWSER_NAME_IE);
    } else if (browserName.equals(BROWSER_NAME_CHROME)) {
        System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_CHROME, "chromedriver.exe");
        caps = DesiredCapabilities.chrome();

        // Disable extensions to avoid popping up 'Disable developer mode extensions' message by default.
        if (!extraParameters.containsKey(KEY_CHROME_DISABLE_EXTENSIONS)) {
            // Only execute if no user's setting
            extraParameters.put(KEY_CHROME_DISABLE_EXTENSIONS, "true");
        }

        //caps.setCapability("browserName", BROWSER_NAME_CHROME);
    } else if (browserName.equals(BROWSER_NAME_EDGE)) {
        System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_EDGE, "MicrosoftWebDriver.exe");
        caps = DesiredCapabilities.edge();
        //caps.setCapability("browserName", BROWSER_NAME_EDGE);
    } else if (browserName.equals(BROWSER_NAME_ANDROID_CHROME)) {
        System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_CHROME, "chromedriver.exe");
        caps = DesiredCapabilities.chrome();
        ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.setExperimentalOption("androidPackage", "com.android.chrome");
        caps.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
        caps.setCapability(CapabilityType.BROWSER_NAME, BROWSER_NAME_CHROME);
    } else if (browserName.equals(BROWSER_NAME_IPAD_SIMULATOR_SAFARI)) {
        caps = new DesiredCapabilities();
        caps.setCapability("device", "ipad");
        caps.setCapability("simulator", "true");
        caps.setCapability(CapabilityType.BROWSER_NAME, "safari");
    } else { // default browser always
        caps = DesiredCapabilities.firefox();
        caps.setCapability(CapabilityType.BROWSER_NAME, BROWSER_NAME_FIREFOX);
    }

    String unexpectedAlertBehaviour = Processor.getUnexpectedAlertBehaviour();
    if (unexpectedAlertBehaviour == null)
        unexpectedAlertBehaviour = System
                .getProperty(DriverConstant.PROERTY_SAFS_TEST_UNEXPECTEDALERTBEHAVIOUR);
    if (unexpectedAlertBehaviour != null) {
        IndependantLog.debug(debugmsg + " Set '" + unexpectedAlertBehaviour + "' to '"
                + CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR + "'.");
        caps.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, unexpectedAlertBehaviour);
    }

    if (extraParameters != null && !extraParameters.isEmpty()) {
        //1. Add http proxy settings to Capabilities, if they exist 
        Object proxysetting = extraParameters.get(KEY_PROXY_SETTING);
        if (proxysetting != null && proxysetting instanceof String) {
            org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
            proxy.setHttpProxy(proxysetting.toString());

            Object bypass = extraParameters.get(KEY_PROXY_BYPASS_ADDRESS);
            if (bypass != null && bypass instanceof String) {
                proxy.setNoProxy(bypass.toString());
            }

            caps.setCapability(CapabilityType.PROXY, proxy);
        }

        //2 Add firefox profile setting to Capabilities.
        if (BROWSER_NAME_FIREFOX.equals(browserName)) {
            //2.1 Add firefox profile setting to Capabilities, if it exists
            FirefoxProfile firefoxProfile = null;
            Object firefoxProfileParam = extraParameters.get(KEY_FIREFOX_PROFILE);
            if (firefoxProfileParam != null && firefoxProfileParam instanceof String) {
                //Can be profile's name or profile's file name
                String profileNameOrPath = firefoxProfileParam.toString();
                IndependantLog.debug(
                        debugmsg + "Try to Set firefox profile '" + profileNameOrPath + "' to Capabilities.");

                firefoxProfile = getFirefoxProfile(profileNameOrPath);

                if (firefoxProfile != null) {
                    caps.setCapability(KEY_FIREFOX_PROFILE, profileNameOrPath);//used to store in session file
                } else {
                    IndependantLog.error(debugmsg + " Fail to set firefox profile to Capabilities.");
                }
            }
            //2.2 Add firefox profile preferences to Capabilities, if it exists
            Object prefsFileParam = extraParameters.get(KEY_FIREFOX_PROFILE_PREFERENCE);
            if (prefsFileParam != null && prefsFileParam instanceof String) {
                String preferenceFile = prefsFileParam.toString();
                IndependantLog.debug(debugmsg + "Try to Set firefox preference file '" + preferenceFile
                        + "' to Firefox Profile.");
                caps.setCapability(KEY_FIREFOX_PROFILE_PREFERENCE, preferenceFile);//used to store in session file

                Map<?, ?> firefoxPreference = Json.readJSONFileUTF8(preferenceFile);
                if (firefoxProfile == null)
                    firefoxProfile = new FirefoxProfile();
                addFireFoxPreference(firefoxProfile, firefoxPreference);
            }

            if (firefoxProfile != null) {
                caps.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
            }
        }

        //3. Add chrome-options-settings to Capabilities.
        if (BROWSER_NAME_CHROME.equals(browserName) || BROWSER_NAME_ANDROID_CHROME.equals(browserName)) {
            setChromeCapabilities(caps, extraParameters);
        }

        //put extra grid-nodes information
        Object gridnodes = extraParameters.get(KEY_GRID_NODES_SETTING);
        if (gridnodes != null && gridnodes instanceof String) {
            caps.setCapability(KEY_GRID_NODES_SETTING, gridnodes);
        }
    }

    return caps;
}