Table of Contents

Class ChromeOptions

Namespace
OpenQA.Selenium.Chrome
Assembly
WebDriver.dll

Class to manage options specific to ChromeDriver

public class ChromeOptions
Inheritance
ChromeOptions
Inherited Members

Examples

ChromeOptions options = new ChromeOptions();
options.AddExtensions("\path\to\extension.crx");
options.BinaryLocation = "\path\to\chrome";

For use with ChromeDriver:

ChromeDriver driver = new ChromeDriver(options);

For use with RemoteWebDriver:

RemoteWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), options.ToCapabilities());

Remarks

Used with ChromeDriver.exe v17.0.963.0 and higher.

Constructors

ChromeOptions()

public ChromeOptions()

Fields

Capability

Gets the name of the capability used to store Chrome options in a DesiredCapabilities object.

public static readonly string Capability

Field Value

string

Properties

Arguments

Gets the list of arguments appended to the Chrome command line as a string array.

public ReadOnlyCollection<string> Arguments { get; }

Property Value

ReadOnlyCollection<string>

BinaryLocation

Gets or sets the location of the Chrome browser's binary executable file.

public string BinaryLocation { get; set; }

Property Value

string

DebuggerAddress

Gets or sets the address of a Chrome debugger server to connect to. Should be of the form "{hostname|IP address}:port".

public string DebuggerAddress { get; set; }

Property Value

string

Extensions

Gets the list of extensions to be installed as an array of base64-encoded strings.

public ReadOnlyCollection<string> Extensions { get; }

Property Value

ReadOnlyCollection<string>

LeaveBrowserRunning

Gets or sets a value indicating whether Chrome should be left running after the ChromeDriver instance is exited. Defaults to false.

public bool LeaveBrowserRunning { get; set; }

Property Value

bool

MinidumpPath

Gets or sets the directory in which to store minidump files.

public string MinidumpPath { get; set; }

Property Value

string

Proxy

Gets or sets the proxy to use with this instance of Chrome.

public Proxy Proxy { get; set; }

Property Value

Proxy

Methods

AddAdditionalCapability(string, object)

Provides a means to add additional capabilities not yet added as type safe options for the Chrome driver.

public void AddAdditionalCapability(string capabilityName, object capabilityValue)

Parameters

capabilityName string

The name of the capability to add.

capabilityValue object

The value of the capability to add.

Remarks

Calling AddAdditionalCapability(string, object) where capabilityName has already been added will overwrite the existing value with the new value in capabilityValue. Also, by default, calling this method adds capabilities to the options object passed to chromedriver.exe.

Exceptions

ArgumentException

thrown when attempting to add a capability for which there is already a type safe option, or when capabilityName is null or the empty string.

AddAdditionalCapability(string, object, bool)

Provides a means to add additional capabilities not yet added as type safe options for the Chrome driver.

public void AddAdditionalCapability(string capabilityName, object capabilityValue, bool isGlobalCapability)

Parameters

capabilityName string

The name of the capability to add.

capabilityValue object

The value of the capability to add.

isGlobalCapability bool

Indicates whether the capability is to be set as a global capability for the driver instead of a Chrome-specific option.

Remarks

Calling AddAdditionalCapability(string, object, bool) where capabilityName has already been added will overwrite the existing value with the new value in capabilityValue

Exceptions

ArgumentException

thrown when attempting to add a capability for which there is already a type safe option, or when capabilityName is null or the empty string.

AddArgument(string)

Adds a single argument to the list of arguments to be appended to the Chrome.exe command line.

public void AddArgument(string argument)

Parameters

argument string

The argument to add.

AddArguments(IEnumerable<string>)

Adds arguments to be appended to the Chrome.exe command line.

public void AddArguments(IEnumerable<string> argumentsToAdd)

Parameters

argumentsToAdd IEnumerable<string>

An IEnumerable<T> object of arguments to add.

AddArguments(params string[])

Adds arguments to be appended to the Chrome.exe command line.

public void AddArguments(params string[] argumentsToAdd)

Parameters

argumentsToAdd string[]

An array of arguments to add.

AddEncodedExtension(string)

Adds a base64-encoded string representing a Chrome extension to the list of extensions to be installed in the instance of Chrome.

public void AddEncodedExtension(string extension)

Parameters

extension string

A base64-encoded string representing the extension to add.

AddEncodedExtensions(IEnumerable<string>)

Adds a list of base64-encoded strings representing Chrome extensions to be installed in the instance of Chrome.

public void AddEncodedExtensions(IEnumerable<string> extensions)

Parameters

extensions IEnumerable<string>

An IEnumerable<T> of base64-encoded strings representing the extensions to add.

AddEncodedExtensions(params string[])

Adds a list of base64-encoded strings representing Chrome extensions to the list of extensions to be installed in the instance of Chrome.

public void AddEncodedExtensions(params string[] extensions)

Parameters

extensions string[]

An array of base64-encoded strings representing the extensions to add.

AddExcludedArgument(string)

Adds a single argument to be excluded from the list of arguments passed by default to the Chrome.exe command line by chromedriver.exe.

public void AddExcludedArgument(string argument)

Parameters

argument string

The argument to exclude.

AddExcludedArguments(IEnumerable<string>)

Adds arguments to be excluded from the list of arguments passed by default to the Chrome.exe command line by chromedriver.exe.

public void AddExcludedArguments(IEnumerable<string> argumentsToExclude)

Parameters

argumentsToExclude IEnumerable<string>

An IEnumerable<T> object of arguments to exclude.

AddExcludedArguments(params string[])

Adds arguments to be excluded from the list of arguments passed by default to the Chrome.exe command line by chromedriver.exe.

public void AddExcludedArguments(params string[] argumentsToExclude)

Parameters

argumentsToExclude string[]

An array of arguments to exclude.

AddExtension(string)

Adds a path to a packed Chrome extension (.crx file) to the list of extensions to be installed in the instance of Chrome.

public void AddExtension(string pathToExtension)

Parameters

pathToExtension string

The full path to the extension to add.

AddExtensions(IEnumerable<string>)

Adds a list of paths to packed Chrome extensions (.crx files) to be installed in the instance of Chrome.

public void AddExtensions(IEnumerable<string> extensions)

Parameters

extensions IEnumerable<string>

An IEnumerable<T> of full paths to the extensions to add.

AddExtensions(params string[])

Adds a list of paths to packed Chrome extensions (.crx files) to be installed in the instance of Chrome.

public void AddExtensions(params string[] extensions)

Parameters

extensions string[]

An array of full paths to the extensions to add.

AddLocalStatePreference(string, object)

Adds a preference for the local state file in the user's data directory for Chrome. If the specified preference already exists, it will be overwritten.

public void AddLocalStatePreference(string preferenceName, object preferenceValue)

Parameters

preferenceName string

The name of the preference to set.

preferenceValue object

The value of the preference to set.

AddUserProfilePreference(string, object)

Adds a preference for the user-specific profile or "user data directory." If the specified preference already exists, it will be overwritten.

public void AddUserProfilePreference(string preferenceName, object preferenceValue)

Parameters

preferenceName string

The name of the preference to set.

preferenceValue object

The value of the preference to set.

ToCapabilities()

Returns DesiredCapabilities for Chrome with these options included as capabilities. This does not copy the options. Further changes will be reflected in the returned capabilities.

public ICapabilities ToCapabilities()

Returns

ICapabilities

The DesiredCapabilities for Chrome with these options.