selenium-webdriver/chromium~ Options

Class for managing WebDriver options specific to a Chromium-based browser.

Constructor

new Options(otheropt)

Parameters:
NameTypeAttributesDescription
otherCapabilities | Map.<string, ?> | Object<optional>

Another set of capabilities to initialize this instance from.

Methods

addArguments(…args) → (non-null) {Options}

Add additional command line arguments to use when launching the browser. Each argument may be specified with or without the "--" prefix (e.g. "--foo" and "foo"). Arguments with an associated value should be delimited by an "=": "foo=bar".

Parameters:
NameTypeAttributesDescription
argsstring | !Array.<string><repeatable>

The arguments to add.

Returns:

A self reference.

Type: 
Options

addExtensions(…args) → (non-null) {Options}

Add additional extensions to install when launching the browser. Each extension should be specified as the path to the packed CRX file, or a Buffer for an extension.

Parameters:
NameTypeAttributesDescription
argsstring | Buffer | !Array.<(string|!Buffer)><repeatable>

The extensions to add.

Returns:

A self reference.

Type: 
Options

androidActivity(name) → (non-null) {Options}

Sets the name of the activity hosting a Chrome-based Android WebView. This option must be set to connect to an Android WebView

Parameters:
NameTypeDescription
namestring

The activity name.

Returns:

A self reference.

Type: 
Options

androidDeviceSerial(serial) → (non-null) {Options}

Sets the device serial number to connect to via ADB. If not specified, the WebDriver server will select an unused device at random. An error will be returned if all devices already have active sessions.

Parameters:
NameTypeDescription
serialstring

The device serial number to connect to.

Returns:

A self reference.

Type: 
Options

androidPackage(pkgnullable) → (non-null) {Options}

Sets the package name of the Chrome or WebView app.

Parameters:
NameTypeAttributesDescription
pkgstring<nullable>

The package to connect to, or null to disable Android and switch back to using desktop browser.

Returns:

A self reference.

Type: 
Options

androidProcess(processName) → (non-null) {Options}

Sets the process name of the Activity hosting the WebView (as given by ps). If not specified, the process name is assumed to be the same as #androidPackage.

Parameters:
NameTypeDescription
processNamestring

The main activity name.

Returns:

A self reference.

Type: 
Options

androidUseRunningApp(useRunning) → (non-null) {Options}

Sets whether to connect to an already-running instead of the specified app instead of launching the app with a clean data directory.

Parameters:
NameTypeDescription
useRunningboolean

Whether to connect to a running instance.

Returns:

A self reference.

Type: 
Options

debuggerAddress(address) → (non-null) {Options}

Sets the address of a Chromium remote debugging server to connect to. Address should be of the form "{hostname|IP address}:port" (e.g. "localhost:9222").

Parameters:
NameTypeDescription
addressstring

The address to connect to.

Returns:

A self reference.

Type: 
Options

detachDriver(detach) → (non-null) {Options}

Sets whether to leave the started browser process running if the controlling driver service is killed before webdriver.WebDriver#quit() is called.

Parameters:
NameTypeDescription
detachboolean

Whether to leave the browser running if the driver service is killed before the session.

Returns:

A self reference.

Type: 
Options

enableBidi() → (non-null) {Capabilities}

Enable bidi connection

Returns:
Type: 
Capabilities

excludeSwitches(…args) → (non-null) {Options}

List of Chrome command line switches to exclude that ChromeDriver by default passes when starting Chrome. Do not prefix switches with "--".

Parameters:
NameTypeAttributesDescription
argsstring | !Array.<string><repeatable>

The switches to exclude.

Returns:

A self reference.

Type: 
Options

setBinaryPath(path) → (non-null) {Options}

Sets the path to the browser binary to use. On Mac OS X, this path should reference the actual Chromium executable, not just the application binary (e.g. "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome").

The binary path can be absolute or relative to the WebDriver server executable, but it must exist on the machine that will launch the browser.

Parameters:
NameTypeDescription
pathstring

The path to the browser binary to use.

Returns:

A self reference.

Type: 
Options

setBrowserLogFile(path) → (non-null) {Options}

Sets the path to the browser's log file. This path should exist on the machine that will launch the browser.

Parameters:
NameTypeDescription
pathstring

Path to the log file to use.

Returns:

A self reference.

Type: 
Options

setBrowserMinidumpPath(path) → (non-null) {Options}

Sets the directory to store browser minidumps in. This option is only supported when the driver is running on Linux.

Parameters:
NameTypeDescription
pathstring

The directory path.

Returns:

A self reference.

Type: 
Options

setLocalState(statenon-null) → (non-null) {Options}

Sets preferences for the "Local State" file in Chrome's user data directory.

Parameters:
NameTypeDescription
stateObject

Dictionary of local state preferences.

Returns:

A self reference.

Type: 
Options

setMobileEmulation(confignullable) → (non-null) {Options}

Configures the browser to emulate a mobile device. For more information, refer to the ChromeDriver project page on mobile emulation. Configuration options include:

  • deviceName: The name of a pre-configured emulated device
  • width: screen width, in pixels
  • height: screen height, in pixels
  • pixelRatio: screen pixel ratio

Example 1: Using a Pre-configured Device

let options = new chrome.Options().setMobileEmulation(
    {deviceName: 'Google Nexus 5'});

let driver = chrome.Driver.createSession(options);

Example 2: Using Custom Screen Configuration

let options = new chrome.Options().setMobileEmulation({deviceMetrics: {
    width: 360,
    height: 640,
    pixelRatio: 3.0
}});

let driver = chrome.Driver.createSession(options);
Parameters:
NameTypeAttributesDescription
configObject | Object<nullable>

The mobile emulation configuration, or null to disable emulation.

Returns:

A self reference.

Type: 
Options

setPerfLoggingPrefs(prefs) → (non-null) {Options}

Sets the performance logging preferences. Options include:

  • enableNetwork: Whether or not to collect events from Network domain.
  • enablePage: Whether or not to collect events from Page domain.
  • enableTimeline: Whether or not to collect events from Timeline domain. Note: when tracing is enabled, Timeline domain is implicitly disabled, unless enableTimeline is explicitly set to true.
  • traceCategories: A comma-separated string of Chromium tracing categories for which trace events should be collected. An unspecified or empty string disables tracing.
  • bufferUsageReportingInterval: The requested number of milliseconds between DevTools trace buffer usage events. For example, if 1000, then once per second, DevTools will report how full the trace buffer is. If a report indicates the buffer usage is 100%, a warning will be issued.
Parameters:
NameTypeDescription
prefsObject

The performance logging preferences.

Returns:

A self reference.

Type: 
Options

setUserPreferences(prefsnon-null) → (non-null) {Options}

Sets the user preferences for Chrome's user profile. See the "Preferences" file in Chrome's user data directory for examples.

Parameters:
NameTypeDescription
prefsObject

Dictionary of user preferences to use.

Returns:

A self reference.

Type: 
Options

windowSize(size) → (non-null) {Options}

Sets the initial window size.

Parameters:
NameTypeDescription
sizeObject

The desired window size.

Throws:

if width or height is unspecified, not a number, or less than or equal to 0.

Type
TypeError
Returns:

A self reference.

Type: 
Options

windowTypes(…args) → (non-null) {Options}

Sets a list of the window types that will appear when getting window handles. For access toelements, include "webview" in the list.

Parameters:
NameTypeAttributesDescription
argsstring | !Array.<string><repeatable>

The window types that will appear when getting window handles.

Returns:

A self reference.

Type: 
Options