Customize and configure ChromeDriver sessions for Selenium tests on BrowserStack Automate.
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.
Refer to the following sample capability declaration example where ChromeOptions is being used to start Chrome in incognito mode:
If you are using BrowserStack SDK, you can set the following capabilities in the browserstack.yml file:
```yml platforms: - os: OS X osVersion: Big Sur browserName: Chrome browserVersion: latest chrome: driver: 112.0.5615.28 chromeOptions: args: - incognito - --start-maximized ```
Copy icon Copy snippetBrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.
MutableCapabilities capabilities = new MutableCapabilities(); ChromeOptions options = new ChromeOptions(); options.addArguments("incognito"); // ChromeOptions for starting chrome in incognito mode capabilities.setCapability(ChromeOptions.CAPABILITY, options); // other capability declarations capabilities.setCapability("browserName", "Chrome"); capabilities.setCapability("browserVersion", "latest"); HashMap<String, Object> browserstackOptions = new HashMap<String, Object>(); browserstackOptions.put("os", "Windows"); browserstackOptions.put("osVersion", "10"); capabilities.setCapability("bstack:options", browserstackOptions); public static final String URL = "https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub"; WebDriver driver = new RemoteWebDriver(new URL(URL), capabilities); // rest of the test case goes here var capabilities = { 'bstack:options' : { "chromeOptions" : { "args" : ["incognito"] // ChromeOption to start chrome in incognito mode }, "browserName" : "Chrome", } } using OpenQA.Selenium.Chrome; ChromeOptions options = new ChromeOptions(); options.AddArgument("incognito"); // ChromeOption to start chrome in incognito mode // Other capabilities are declared below ChromeOptions capabilities = new ChromeOptions(); capabilities.BrowserVersion = "latest"; Dictionary<string, object> browserstackOptions = new Dictionary<string, object>(); browserstackOptions.Add("os", "Windows"); browserstackOptions.Add("osVersion", "10"); browserstackOptions.Add("userName", "YOUR_USERNAME"); browserstackOptions.Add("accessKey", "YOUR_ACCESS_KEY"); browserstackOptions.Add("browserName", "Chrome"); capabilities.AddAdditionalOption("bstack:options", browserstackOptions); IWebDriver driver = new RemoteWebDriver( new Uri("https://hub-cloud.browserstack.com/wd/hub/"), capabilities ); // Rest of the test case goes here # Using chromeOptions to start chrome in incognito mode $chromeOptions = array( "args" => array("incognito") ); $caps = array( 'bstack:options' => array( "chromeOptions" => $chromeOptions ) ); # Using chromeOptions to start chrome in incognito mode desired_cap = { 'bstack:options' : { "ChromeOptions" : { "args" : ["incognito"] } }, "browserName" : "Chrome", } # Using chromeOptions to start chrome in incognito mode capabilities = Selenium::WebDriver::Remote::Capabilities.chrome capabilities = { 'bstack:options' => { "ChromeOptions" => { "args" => ["incognito"] } }, "browserName" => "Chrome", } 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"] 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
Yes No
We're sorry to hear that. Please share your feedback so we can do better
Submit
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
Any additional feedback?
Submit
Is this page helping you?
We're sorry to hear that. Please share your feedback so we can do better
Submit Skip
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
Any additional feedback?
Submit Skip
Thank you for your valuable feedback!
ncG1vNJzZmivp6x7o77OsKqeqqOprqS3jZympmeUpLC0e8Cuq6ilkamycL%2FEpZynoaWifKS00aiknmWfpcGqu82s