ChromeDriver Options for starting Chrome with WebDriver

//ChromeDriver Options for starting Chrome with WebDriver

ChromeDriver Options for starting Chrome with WebDriver

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

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

 

Hide the automation toolbar warning

 

Put Chrome into mobile emulation mode

C# example:

 

Java Example:

An alternative is to set individual device attributes, this is a more complex approach, and details can be found at https://sites.google.com/a/chromium.org/chromedriver/mobile-emulation

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:

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

 

Using a Chrome executable in a non-standard location

 

Using Headless Chrome

 

Add Extensions to Chrome

 

Help

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

By | 2017-10-13T09:34:25+00:00 October 13th, 2017|Categories: Selenium WebDriver|Tags: , , , , |0 Comments

About the Author:

Leave A Comment

Contact Info

Lasyard House, Underhill St. Bridgnorth WV16 4BB

Phone: +44 (0)333 939 8884