Page tree
Skip to end of metadata
Go to start of metadata

Last updated: Oct 01, 2019 17:37

Problem

Sometimes there is a need to use Chrome options which are not a part of standard capabilities.

Solution

Starting Selenium version 3.6.0, the ChromeOptions class in Java also implements the Capabilities interface, allowing you to specify other WebDriver capabilities not specific to ChromeDriver.

The code example below shows the passing Chrome Options as capabilities:

ChromeOptions options = new ChromeOptions();

options.addExtensions(new File("/path/to/extension.crx"));

options.addArguments("--disable-web-security");

options.addArguments("--start-maximized");

capabilities.setCapability(ChromeOptions.CAPABILITY, options);

ChromeDriver Options Protractor JS example
 capabilities: {
  browserName: 'chrome',
  chromeOptions: {
     args: [ "--headless", 
             "--disable-gpu", 
             "--window-size=800,600",
             "--debuggerAddress=127.0.0.1:12633" ]
   }
}



Chrome://flags Chrome driver Protractor JS example
capabilities: {
    'platformName' : 'Windows',
    'platformVersion' : '10',
    'browserName' : 'Chrome',
    'browserVersion' : '77',
    'resolution' : '1280x1024',
    'location' : 'US East',
                                securityToken: '',
                                "goog:chromeOptions":  {
        args: ["" ],
        extensions: []
    }
  },

https://chromedriver.chromium.org/capabilities

https://peter.sh/experiments/chromium-command-line-switches/#user-agent

All preferences: https://chromium.googlesource.com/chromium/src/+/master/chrome/common/pref_names.cc

All switches: https://chromium.googlesource.com/chromium/src/+/master/chrome/common/chrome_switches.cc