Webinar - Join us on 26th Oct. to hear all about Selenium 4 and its exciting new features from David Burns, Core Contributor to Selenium. Register here

Set Chrome Options

A ChromeDriver session i.e. a test running on the Chrome browser, can further be customized and configured using ChromeOptions. BrowserStack supports the full complement of ChromeOptions.

Following is a sample capability declaration example where ChromeOptions is being used to start Chrome in incognito mode:

DesiredCapabilities caps = new DesiredCapabilities();
ChromeOptions options = new ChromeOptions();
options.addArguments("incognito");  // ChromeOptions for starting chrome in incognito mode

caps.setCapability(ChromeOptions.CAPABILITY, options);
// other capability declarations
caps.setCapability("browser", "Chrome");
caps.setCapability("browser_version", "latest");
caps.setCapability("os", "Windows");
caps.setCapability("os_version", "10");
public static final String URL = "https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub";
WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
// rest of the test case goes here
var capabilities = {
  "browserName" : "chrome",
  "chromeOptions" : {
    "args" : ["incognito"]  // ChromeOption to start chrome in incognito mode
  }
}
using OpenQA.Selenium.Chrome;

ChromeOptions options = new ChromeOptions();
options.AddArgument("incognito");  // ChromeOption to start chrome in incognito mode

// Other capabilities are declared below
options.AddAdditionalCapability("browser", "Chrome", true);
options.AddAdditionalCapability("browser_version", "latest", true);
options.AddAdditionalCapability("os", "Windows", true);
options.AddAdditionalCapability("os_version", "10", true);
options.AddAdditionalCapability("browserstack.user", "YOUR_USERNAME", true);
options.AddAdditionalCapability("browserstack.key", "YOUR_ACCESS_KEY", true);
IWebDriver driver = new RemoteWebDriver(
    new Uri("https://hub-cloud.browserstack.com/wd/hub/"), capability
);
// Rest of the test case goes here
# Using chromeOptions to start chrome in incognito mode

$chromeOptions = array(
 "args" => array("incognito")
);

$caps = array(
 "chromeOptions" => $chromeOptions
);
# Using chromeOptions to start chrome in incognito mode

desired_cap["chromeOptions"] = {}
desired_cap["chromeOptions"]["args"] = ["incognito"]
# Using chromeOptions to start chrome in incognito mode

caps = Selenium::WebDriver::Remote::Capabilities.chrome
caps["chromeOptions"] = {}
caps["chromeOptions"]["args"] = ["incognito"]
# Using chromeOptions to start chrome in incognito mode

$capabilities->{"chromeOptions"} = {
 "args" => ("incognito")
};
Note: BrowserStack supports all the ChromeOptions that is supported in Selenium tests. You can pass any ChromeOption during the start of your test session similar to the sample ChromeOption declaration code snippet shown above.

Useful references

  1. Read about ChromeDriver and ChromeOptions
  2. List of common ChromeOptions switches
  3. List of headless switches
  4. Search other switches

We're sorry to hear that. Please share your feedback so we can do better







Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better







Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Talk to an Expert