Config

Config

A class that represents a Webdriver configuration

Constructor

new Config()

The main aim of Config class is to provide a configuration object that will be used when creating a new session with the webdriver

A basic (empty) session configuration object looks like this:

   {
     capabilities: {
       alwaysMatch: {
         'goog:chromeOptions': { w3c: true }
       },
       firstMatch: []
     }
   }

Note that goog:chromeOptions is set as this option is necessary to make the Chrome webdriver work with this API.

Configuration options are set with the methods Config#setAlwaysMatch, Config#addFirstMatch, Config#set and Config#setSpecific

Source:

Methods

setAlwaysMatch(path, value, force)

Method to set the alwaysMatch property in the browser's capabilities

Parameters:
Name Type Description
path string

The name of the property to set. It can be a path; if path is has a . (e.g. something.other), the property sessionParameters.capabilities.alwaysMatch.something.other will be set

Properties
Name Type Description
browserName string

The user agent

browserVersion string

Identifies the version of the user agent

platformName string

Identifies the operating system of the endpoint node

acceptInsecureCerts boolean

Indicates whether untrusted and self-signed TLS certificates are implicitly trusted on navigation for the duration of the session

pageLoadStrategy string

Defines the current session’s page load strategy. It can be none, eager or normal

proxy object

Defines the current session’s proxy configuration. See the spec's proxy options

setWindowRect boolean

Indicates whether the remote end supports all of the commands in Resizing and Positioning Windows

timeouts object

Describes the timeouts imposed on certain session operations. Can have keys implicit, pageLoad or script

unhandledPromptBehavior string

Describes the current session’s user prompt handler. It can be: dismiss, accept, dismiss and notify, accept and notify, ignore

value *

The value to assign to the property

force boolean

It will overwrite keys if already present.

Source:
Example
this.setAlwaysMatch('platformName', 'linux')
this.setAlwaysMatch('timeouts.implicit', 10000)

addFirstMatch(key, value, force)

Adds a property to the firstMatch array in the browser's capabilities.

Parameters:
Name Type Description
key string

The name of the property to set

value *

The value to assign

force boolean

It will overwrite keys if needed

Source:
Example
this.addFirstMatch({browserName: 'chrome'})
this.addFirstMatch({browserName: 'firefox'})
NOTE: WAS:
this.addFirstMatch({'browserName', 'chrome')
this.addFirstMatch('browserName', 'firefox')

set(path, value, force)

Sets a key (or a path) on the object which will be sent to the webdriver when creating a session

Parameters:
Name Type Default Description
path string

The name of the property to set. It can be a path; if path is has a . (e.g. something.other), the property sessionParameters.something.other will be set

value *

The value to assign

force boolean true

It will overwrite keys if needed

Source:
Example
this.set('login', 'blah')
this.set('pass', 'blah')

setSpecific(name, path, value, force)

Sets a configuration option for the specific browser.

Parameters:
Name Type Description
name browserName

The name of the browser to set. It can be chrome, firefox, safari or edge

path string

The name of the property to set. It can be a path; if path is has a . (e.g. something.other), the property sessionParameters.something.other will be set

value *

The value to assign

force boolean

It will overwrite keys if needed

Source:
Example
this.setSpecific('chrome', 'FIXME1', 'blah')
this.setSpecific('safari', 'FIXME2', 'blah')

getSessionParameters() → {Object}

Return the current session parameters. This is used by the Driver#newSession call to get the parameters to be sent over

Source: