In this Blog we take a look at some of the options provided with the ChromeDriver Server for starting Chrome with various options when using Selenium WebDriver. The examples are in C# so you may need to tailor for Java.

Set Path to the ChromeDriver Server


WebDriver driver = new ChromeDriver();


or you could add the path to chromedriver.exe in your system path.

Hide the automation toolbar warning

ChromeOptions options = new ChromeOptions();


WebDriver driver = new ChromeDriver(options);

Put Chrome into mobile emulation mode

C# example:

ChromeOptions options = new ChromeOptions();

options.EnableMobileEmulation("Google Nexus 5");

IWebDriver driver = new ChromeDriver(options);

driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);

Java Example:

Map<String, String>; mobileEmulation = new HashMap<String, String>();

mobileEmulation.put("deviceName", "Google Nexus 5");

Map<String, Object> chromeOptions = new HashMap<String, Object>();

chromeOptions.put("mobileEmulation", mobileEmulation);

DesiredCapabilities capabilities =;

capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

WebDriver driver = new ChromeDriver(capabilities);

An alternative is to set individual device attributes, this is a more complex approach, and details can be found at

Use custom profile (also called user data directory)

By default, ChromeDriver will create a new temporary profile for each session. At times you may want to set special preferences or just use a custom profile altogether. If the former, you can use the ‘chrome.prefs’ capability (described later below) to specify preferences that will be applied after Chrome starts. If the latter, you can use the user-data-dir Chrome command-line switch to tell Chrome which profile to use:

ChromeOptions options = new ChromeOptions();


You can create your own custom profile by just running Chrome (on the command-line or through ChromeDriver) with the user-data-dir switch set to some new directory. If the path doesn’t exist, Chrome will create a new profile in the specified location. You can then modify the profile settings as desired, and ChromeDriver can use the profile in the future. Open chrome://version in the browser to see what profile Chrome is using.

Start Chrome maximized

ChromeOptions options = new ChromeOptions();


Using a Chrome executable in a non-standard location

ChromeOptions options = new ChromeOptions();


Using Headless Chrome

ChromeOptions options = new ChromeOptions();


driver = new ChromeDriver(options);

Add Extensions to Chrome

ChromeOptions options = new ChromeOptions();


IWebDriver driver = new ChromeDriver(options);


Run chromedriver --help to see command line arguments for your version.

NOTE: The above examples are in WebDriver C#, for Java, you may need to use options.addArguments