class Options

webdriver.Serializable
  └ Options

Class for managing ChromeDriver specific options.

new Options()

Parameters
None.

Instance Methods

addArguments(var_args)code »

Add additional command line arguments to use when launching the Chrome 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
var_args...(string|Array<string>)

The arguments to add.

Returns
Options

A self reference.


addExtensions(var_args)code »

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

Parameters
var_args...(string|Buffer|Array<(string|Buffer)>)

The extensions to add.

Returns
Options

A self reference.


androidActivity(name)code »

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

Parameters
namestring

The activity name.

Returns
Options

A self reference.


androidChrome()code »

Configures the ChromeDriver to launch Chrome on Android via adb. This function is shorthand for options.androidPackage('com.android.chrome').

Returns
Options

A self reference.


androidDeviceSerial(serial)code »

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

Parameters
serialstring

The device serial number to connect to.

Returns
Options

A self reference.


androidPackage(pkg)code »

Sets the package name of the Chrome or WebView app.

Parameters
pkg?string

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

Returns
Options

A self reference.


androidProcess(processName)code »

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
processNamestring

The main activity name.

Returns
Options

A self reference.


androidUseRunningApp(useRunning)code »

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

Parameters
useRunningboolean

Whether to connect to a running instance.

Returns
Options

A self reference.


detachDriver(detach)code »

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

Parameters
detachboolean

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

Returns
Options

A self reference.


excludeSwitches(var_args)code »

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

Parameters
var_args...(string|Array<string>)

The switches to exclude.

Returns
Options

A self reference.


serialize()code »

Converts this instance to its JSON wire protocol representation. Note this function is an implementation not intended for general use.

Overrides: webdriver.Serializable

Returns
{args: Array<string>, binary: (string|undefined), detach: boolean, extensions: Array<(string|webdriver.promise.Promise)>, localState: ?(Object), logPath: (string|undefined), prefs: ?(Object)}

The JSON wire protocol representation of this instance.


setChromeBinaryPath(path)code »

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

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

Parameters
pathstring

The path to the Chrome binary to use.

Returns
Options

A self reference.


setChromeLogFile(path)code »

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

Parameters
pathstring

Path to the log file to use.

Returns
Options

A self reference.


setChromeMinidumpPath(path)code »

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

Parameters
pathstring

The directory path.

Returns
Options

A self reference.


setLocalState(state)code »

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

Parameters
stateObject

Dictionary of local state preferences.

Returns
Options

A self reference.


setLoggingPrefs(prefs)code »

Sets the logging preferences for the new session.

Parameters
prefswebdriver.logging.Preferences

The logging preferences.

Returns
Options

A self reference.


setMobileEmulation(config)code »

Configures Chrome 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

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

var driver = new chrome.Driver(options);

Example 2: Using Custom Screen Configuration

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

var driver = new chrome.Driver(options);
Parameters
config?({deviceName: string}|{height: number, pixelRatio: number, width: number})

The mobile emulation configuration, or null to disable emulation.

Returns
Options

A self reference.


setPerfLoggingPrefs(prefs)code »

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.
  • tracingCategories: A comma-separated string of Chrome 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
prefs{bufferUsageReportingInterval: number, enableNetwork: boolean, enablePage: boolean, enableTimeline: boolean, tracingCategories: string}

The performance logging preferences.

Returns
Options

A self reference.


setProxy(proxy)code »

Sets the proxy settings for the new session.

Parameters
proxyselenium-webdriver.ProxyConfig

The proxy configuration to use.

Returns
Options

A self reference.


setUserPreferences(prefs)code »

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

Parameters
prefsObject

Dictionary of user preferences to use.

Returns
Options

A self reference.


toCapabilities(opt_capabilities)code »

Converts this options instance to a webdriver.Capabilities object.

Parameters
opt_capabilities?Capabilities=

The capabilities to merge these options into, if any.

Returns
webdriver.Capabilities

The capabilities.

Static Functions

Options.fromCapabilities(capabilities)code »

Extracts the ChromeDriver specific options from the given capabilities object.

Parameters
capabilitiesCapabilities

The capabilities object.

Returns
Options

The ChromeDriver options.