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:

DesiredCapabilities capabilities = DesiredCapabilities.Chrome();
capabilities.SetCapability(ChromeOptions.Capability, options);
RemoteWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capabilities);

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

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>

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

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> arguments)

Parameters

arguments 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[] arguments)

Parameters

arguments string[]

An array of arguments to add.

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.