Table of Contents

Class ChromiumOptions

Namespace
OpenQA.Selenium.Chromium
Assembly
WebDriver.dll

Abstract class to manage options specific to Chromium-based browsers.

public abstract class ChromiumOptions : DriverOptions
Inheritance
ChromiumOptions
Derived
Inherited Members

Constructors

ChromiumOptions()

Initializes a new instance of the ChromiumOptions class.

public ChromiumOptions()

Properties

AndroidOptions

Gets or sets the options for automating Chromium applications on Android.

public ChromiumAndroidOptions? AndroidOptions { get; set; }

Property Value

ChromiumAndroidOptions

Arguments

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

public ReadOnlyCollection<string> Arguments { get; }

Property Value

ReadOnlyCollection<string>

BinaryLocation

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

public override string? BinaryLocation { get; set; }

Property Value

string

CapabilityName

Gets the name of the capability used to store Chromium options in an ICapabilities object.

public abstract string CapabilityName { get; }

Property Value

string

DebuggerAddress

Gets or sets the address of a Chromium 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 Chromium 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

PerformanceLoggingPreferences

Gets or sets the performance logging preferences for the driver.

public ChromiumPerformanceLoggingPreferences? PerformanceLoggingPreferences { get; set; }

Property Value

ChromiumPerformanceLoggingPreferences

VendorPrefix

Gets the vendor prefix to apply to Chromium-specific capability names.

protected abstract string VendorPrefix { get; }

Property Value

string

Methods

AddAdditionalChromiumOption(string, object)

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

protected void AddAdditionalChromiumOption(string optionName, object optionValue)

Parameters

optionName string

The name of the capability to add.

optionValue object

The value of the capability to add.

Remarks

Calling AddAdditionalChromiumOption(string, object) where optionName has already been added will overwrite the existing value with the new value in optionValue. Calling this method adds capabilities to the Chromium-specific options object passed to webdriver executable (e.g. property name 'goog:chromeOptions').

Exceptions

ArgumentException

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

ArgumentException

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

AddArgument(string)

Adds a single argument to the list of arguments to be appended to the browser executable command line.

public void AddArgument(string argument)

Parameters

argument string

The argument to add.

Exceptions

ArgumentException

If argument is null or Empty.

AddArguments(IEnumerable<string>)

Adds arguments to be appended to the browser executable command line.

public void AddArguments(IEnumerable<string> argumentsToAdd)

Parameters

argumentsToAdd IEnumerable<string>

An IEnumerable<T> object of arguments to add.

Exceptions

ArgumentNullException

If argumentsToAdd is null.

AddArguments(params string[])

Adds arguments to be appended to the browser executable command line.

public void AddArguments(params string[] argumentsToAdd)

Parameters

argumentsToAdd string[]

An array of arguments to add.

Exceptions

ArgumentNullException

If argumentsToAdd is null.

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.

Exceptions

ArgumentException

If extension is null or Empty.

WebDriverException

If the extension string is not valid base-64.

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.

Exceptions

ArgumentNullException

If extensions is null.

WebDriverException

If an extension string is not valid base-64.

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.

Exceptions

ArgumentNullException

If extensions is null.

WebDriverException

If an extension string is not valid base-64.

AddExcludedArgument(string)

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

public void AddExcludedArgument(string argument)

Parameters

argument string

The argument to exclude.

Exceptions

ArgumentException

If argument is null or Empty.

AddExcludedArguments(IEnumerable<string>)

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

public void AddExcludedArguments(IEnumerable<string> argumentsToExclude)

Parameters

argumentsToExclude IEnumerable<string>

An IEnumerable<T> object of arguments to exclude.

Exceptions

ArgumentNullException

If argumentsToExclude is null.

AddExcludedArguments(params string[])

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

public void AddExcludedArguments(params string[] argumentsToExclude)

Parameters

argumentsToExclude string[]

An array of arguments to exclude.

Exceptions

ArgumentNullException

If argumentsToExclude is null.

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.

Exceptions

ArgumentException

If pathToExtension is null or Empty.

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.

Exceptions

ArgumentNullException

If extensions is null.

FileNotFoundException

If any extension file path does not point to a file.

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.

Exceptions

ArgumentNullException

If extensions is null.

FileNotFoundException

If any extension file path does not point to a file.

AddLocalStatePreference(string, object)

Adds a preference for the local state file in the user's data directory for Chromium. 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.

Exceptions

ArgumentNullException

If preferenceName is null.

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.

Exceptions

ArgumentNullException

If preferenceName is null.

AddVendorSpecificChromiumCapabilities(IWritableCapabilities)

Adds vendor-specific capabilities for Chromium-based browsers.

protected virtual void AddVendorSpecificChromiumCapabilities(IWritableCapabilities capabilities)

Parameters

capabilities IWritableCapabilities

The capabilities to add.

AddWindowType(string)

Adds a type of window that will be listed in the list of window handles returned by the Chrome driver.

public void AddWindowType(string windowType)

Parameters

windowType string

The name of the window type to add.

Remarks

This method can be used to allow the driver to access {webview} elements by adding "webview" as a window type.

Exceptions

ArgumentException

If windowType is null or Empty.

AddWindowTypes(IEnumerable<string>)

Adds a list of window types that will be listed in the list of window handles returned by the Chromium driver.

public void AddWindowTypes(IEnumerable<string> windowTypesToAdd)

Parameters

windowTypesToAdd IEnumerable<string>

An IEnumerable<T> of window types to add.

Exceptions

ArgumentNullException

If windowTypesToAdd is null.

AddWindowTypes(params string[])

Adds a list of window types that will be listed in the list of window handles returned by the Chromium driver.

public void AddWindowTypes(params string[] windowTypesToAdd)

Parameters

windowTypesToAdd string[]

An array of window types to add.

Exceptions

ArgumentNullException

If windowTypesToAdd is null.

EnableMobileEmulation(ChromiumMobileEmulationDeviceSettings?)

Allows the Chromium browser to emulate a mobile device.

public void EnableMobileEmulation(ChromiumMobileEmulationDeviceSettings? deviceSettings)

Parameters

deviceSettings ChromiumMobileEmulationDeviceSettings

The ChromiumMobileEmulationDeviceSettings object containing the settings of the device to emulate.

Remarks

Specifying an invalid device name will not throw an exeption, but will generate an error in Chrome when the driver starts. To unset mobile emulation, call this method with null as the argument.

Exceptions

ArgumentException

Thrown if the device settings option does not have a user agent string set.

EnableMobileEmulation(string?)

Allows the Chromium browser to emulate a mobile device.

public void EnableMobileEmulation(string? deviceName)

Parameters

deviceName string

The name of the device to emulate. The device name must be a valid device name from the Chrome DevTools Emulation panel.

Remarks

Specifying an invalid device name will not throw an exeption, but will generate an error in Chrome when the driver starts. To unset mobile emulation, call this method with null as the argument.

ToCapabilities()

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

public override ICapabilities ToCapabilities()

Returns

ICapabilities

The DesiredCapabilities for Chrome with these options.