Options
Based on the setup type (e.g. using the raw protocol bindings, WebdriverIO as standalone package or the WDIO testrunner) there is a different set of options available to control the environment.
#
WebDriver OptionsThe following options are defined when using the webdriver
protocol package:
#
protocolProtocol to use when communicating with the driver server.
Type: String
Default: http
#
hostnameHost of your driver server.
Type: String
Default: localhost
#
portPort your driver server is on.
Type: Number
Default: 4444
#
pathPath to driver server endpoint.
Type: String
Default: /
#
queryParamsQuery parameters that are propagated to the driver server.
Type: Object
Default: null
#
userYour cloud service username (only works for Sauce Labs, Browserstack, TestingBot, CrossBrowserTesting or LambdaTest accounts). If set, WebdriverIO will automatically set connection options for you. If you don't use a cloud provider this can be used to authenticate any other WebDriver backend.
Type: String
Default: null
#
keyYour cloud service access key or secret key (only works for Sauce Labs, Browserstack, TestingBot, CrossBrowserTesting or LambdaTest accounts). If set, WebdriverIO will automatically set connection options for you. If you don't use a cloud provider this can be used to authenticate any other WebDriver backend.
Type: String
Default: null
#
capabilitiesDefines the capabilities you want to run in your WebDriver session. Check out the WebDriver Protocol for more details. If you run an older driver that doesn't support the WebDriver protocol, you’ll need to use the JSONWireProtocol capabilities to successfully run a session.
Additionally, a useful utility is the Sauce Labs Automated Test Configurator, which helps you create this object by clicking together your desired capabilities.
Type: Object
Default: null
Example:
If you’re running web or native tests on mobile devices, capabilities
differs from the WebDriver protocol. See the Appium Docs for more details.
#
logLevelLevel of logging verbosity.
Type: String
Default: info
Options: trace
| debug
| info
| warn
| error
| silent
#
outputDirDirectory to store all testrunner log files (including reporter logs and wdio
logs). If not set, all logs are streamed to stdout
. Since most reporters are made to log to stdout
, it is recommended to only use this option for specific reporters where it makes more sense to push report into a file (like the junit
reporter, for example).
When running in standalone mode, the only log generated by WebdriverIO will be the wdio
log.
Type: String
Default: null
#
connectionRetryTimeoutTimeout for any WebDriver request to a driver or grid.
Type: Number
Default: 120000
#
connectionRetryCountMaximum count of request retries to the Selenium server.
Type: Number
Default: 3
#
agentAllows you to use a custom http
/https
/http2
agent to make requests.
Type: Object
Default:
#
headersSpecify custom headers
to pass into every request.
Type: Object
Default: {}
#
transformRequestFunction intercepting HTTP request options before a WebDriver request is made
Type: (RequestOptions) => RequestOptions
Default: none
#
transformResponseFunction intercepting HTTP response objects after a WebDriver response has arrived. The function is passed the original response object as the first and the corresponding RequestOptions
as the second argument.
Type: (Response, RequestOptions) => Response
Default: none
#
strictSSLWhether it does not require SSL certificate to be valid.
It can be set via an environment variables as STRICT_SSL
or strict_ssl
.
Type: Boolean
Default: true
#
WebdriverIOThe following options (including the ones listed above) can be used with WebdriverIO in standalone:
#
automationProtocolDefine the protocol you want to use for your browser automation. Currently only webdriver
and devtools
are supported, as these are the main browser automation technologies available.
If you want to automate the browser using devtools
, make sure you have the NPM package installed ($ npm install --save-dev devtools
).
Type: String
Default: webdriver
#
baseUrlShorten url
command calls by setting a base URL.
- If your
url
parameter starts with/
, thenbaseUrl
is prepended (except thebaseUrl
path, if it has one). - If your
url
parameter starts without a scheme or/
(likesome/path
), then the fullbaseUrl
is prepended directly.
Type: String
Default: null
#
waitforTimeoutDefault timeout for all waitFor*
commands. (Note the lowercase f
in the option name.) This timeout only affects commands starting with waitFor*
and their default wait time.
To increase the timeout for a test, please see the framework docs.
Type: Number
Default: 3000
#
waitforIntervalDefault interval for all waitFor*
commands to check if an expected state (e.g., visibility) has been changed.
Type: Number
Default: 500
#
regionIf running on Sauce Labs, you can choose to run tests between different datacenters: US or EU.
To change your region to EU, add region: 'eu'
to your config.
Note: This only has an effect if you provide user
and key
options that are connected to your Sauce Labs account.
Type: String
Default: us
(only for vm and or em/simulators)
#
headlessSauce Labs provides a headless offering that allows you to run Chrome and Firefox tests headless.
Note: This only has an effect if you provide user
and key
options that are connected to your Sauce Labs account.
Type: Boolean
Default: false
(only for VM or EM/simulators)
#
Testrunner OptionsThe following options (including the ones listed above) are defined only for running WebdriverIO with the WDIO testrunner:
#
specsDefine specs for test execution.
Type: String[]
Default: []
#
excludeExclude specs from test execution.
Type: String[]
Default: []
#
suitesAn object describing various of suites, which you can then specify with the --suite
option on the wdio
CLI.
Type: Object
Default: {}
#
capabilitiesThe same as the capabilities
section described above, except with the option to specify either a multiremote
object, or multiple WebDriver sessions in an array for parallel execution.
Type: Object
|Object[]
Default: [{ maxInstances: 5, browserName: 'firefox' }]
#
maxInstancesMaximum number of total parallel running workers.
Type: Number
Default: 100
#
maxInstancesPerCapabilityMaximum number of total parallel running workers per capability.
Type: Number
Default: 100
#
bailIf you want your test run to stop after a specific number of test failures, use bail
.
(It defaults to 0
, which runs all tests no matter what.) Note: Please be aware that when using a third party test runner (such as Mocha), additional configuration might be required.
Type: Number
Default: 0
(don't bail; run all tests)
#
specFileRetriesThe number of times to retry an entire specfile when it fails as a whole.
Type: Number
Default: 0
#
specFileRetriesDelayDelay in seconds between the spec file retry attempts
Type: Number
Default: 0
#
specFileRetriesDeferredWhether or not retried specfiles should be retried immediately or deferred to the end of the queue.
Type: Boolean
Default: true
#
servicesServices take over a specific job you don't want to take care of. They enhance your test setup with almost no effort.
Type: String[]|Object[]
Default: []
#
frameworkDefines the test framework to be used by the WDIO testrunner.
Type: String
Default: mocha
Options: mocha
| jasmine
#
mochaOpts, jasmineNodeOpts and cucumberOptsSpecific framework-related options. See the framework adapter documentation on which options are available. Read more on this in Frameworks.
Type: Object
Default: { timeout: 10000 }
#
cucumberFeaturesWithLineNumbersList of cucumber features with line numbers (when using cucumber framework).
Type: String[]
Default: []
#
reportersList of reporters to use. A reporter can be either a string, or an array of
['reporterName', { /* reporter options */}]
where the first element is a string with the reporter name and the second element an object with reporter options.
Type: String[]|Object[]
Default: []
Example:
#
reporterSyncIntervalDetermines in which interval the reporter should check if they are synchronised if they report their logs asynchronously (e.g. if logs are streamed to a 3rd party vendor).
Type: Number
Default: 100
(ms)
#
reporterSyncTimeoutDetermines the maximum time reporters have to finish uploading all their logs until an error is being thrown by the testrunner.
Type: Number
Default: 5000
(ms)
#
execArgvNode arguments to specify when launching child processes.
Type: String[]
Default: null
#
HooksThe WDIO testrunner allows you to set hooks to be triggered at specific times of the test lifecycle. This allows custom actions (e.g. take screenshot if a test fails).
Every hook has as parameter specific information about the lifecycle (e.g. information about the test suite or test). Read more about all hook properties in our example config.
Note: Some hooks (onPrepare
, onWorkerStart
and onComplete
) are executed in a different process and therefor can not share any global data with the other hooks that live in the worker process.
#
onPrepareGets executed once before all workers get launched.
Parameters:
config
(object
): WebdriverIO configuration objectparam
(object[]
): list of capabilities details
#
onWorkerStartGets executed before a worker process is spawned and can be used to initialise specific service for that worker as well as modify runtime environments in an async fashion.
Parameters:
cid
(string
): capability id (e.g 0-0)caps
(object
): containing capabilities for session that will be spawn in the workerspecs
(string[]
): specs to be run in the worker processargs
(object
): object that will be merged with the main configuration once worker is initialisedexecArgv
(string[]
): list of string arguments passed to the worker process
#
beforeSessionGets executed just before initialising the webdriver session and test framework. It allows you to manipulate configurations depending on the capability or spec.
Parameters:
config
(object
): WebdriverIO configuration objectcaps
(object
): containing capabilities for session that will be spawn in the workerspecs
(string[]
): specs to be run in the worker process
#
beforeGets executed before test execution begins. At this point you can access to all global variables like browser
. It is the perfect place to define custom commands.
Parameters:
caps
(object
): containing capabilities for session that will be spawn in the workerspecs
(string[]
): specs to be run in the worker processbrowser
(object
): instance of created browser/device session
#
beforeSuiteHook that gets executed before the suite starts
Parameters:
suite
(object
): suite details
#
beforeHookHook that gets executed before a hook within the suite starts (e.g. runs before calling beforeEach in Mocha)
Parameters:
test
(object
): test detailscontext
(object
): test contextstepData
(object
): step data (Cucumber only)world
(object
): world context (Cucumber only)
#
afterHookHook that gets executed after a hook within the suite ends (e.g. runs after calling afterEach in Mocha)
Parameters:
test
(object
): test detailscontext
(object
): test contextresult
(object
): hook result (containserror
,result
,duration
,passed
,retries
properties)stepData
(object
): step data (Cucumber only)world
(object
): world context (Cucumber only)
#
beforeTestFunction to be executed before a test (in Mocha/Jasmine) starts.
Parameters:
test
(object
): test detailscontext
(object
): test context
#
beforeCommandRuns before a WebdriverIO command gets executed.
Parameters:
commandName
(string
): command nameargs
(*
): arguments that command would receive
#
afterCommandRuns after a WebdriverIO command gets executed.
Parameters:
commandName
(string
): command nameargs
(*
): arguments that command would receiveresult
(number
): 0 - command success, 1 - command errorerror
(Error
): error object if any
#
afterTestFunction to be executed after a test (in Mocha/Jasmine) ends.
Parameters:
test
(object
): test detailscontext
(object
): test contextresult
(object
): hook result (containserror
,result
,duration
,passed
,retries
properties)
#
afterSuiteHook that gets executed after the suite has ended
Parameters:
suite
(object
): suite details
#
afterGets executed after all tests are done. You still have access to all global variables from the test.
Parameters:
result
(number
): 0 - test pass, 1 - test failcaps
(object
): containing capabilities for session that will be spawn in the workerspecs
(string[]
): specs to be run in the worker process
#
afterSessionGets executed right after terminating the webdriver session.
Parameters:
config
(object
): WebdriverIO configuration objectcaps
(object
): containing capabilities for session that will be spawn in the workerspecs
(string[]
): specs to be run in the worker process
#
onCompleteGets executed after all workers got shut down and the process is about to exit. An error thrown in the onComplete hook will result in the test run failing.
Parameters:
exitCode
(number
): 0 - success, 1 - failconfig
(object
): WebdriverIO configuration objectcaps
(object
): containing capabilities for session that will be spawn in the workerresult
(object
): results object containing test results
#
onReloadGets executed when a refresh happens.
Parameters:
oldSessionId
(string
): session ID of the old sessionnewSessionId
(string
): session ID of the new session
#
beforeFeatureRuns before a Cucumber Feature.
Parameters:
uri
: (string
): path to feature filefeature
: (object
): Cucumber feature objectscenario
: (object
): Cucumber scenario object
#
afterFeatureRuns after a Cucumber Feature.
Parameters:
uri
: (string
): path to feature filefeature
: (object
): Cucumber feature objectscenario
: (object
): Cucumber scenario object
#
beforeScenarioRuns before a Cucumber Scenario.
Parameters:
uri
: (string
): path to feature filefeature
: (object
): Cucumber feature objectscenario
: (object
): Cucumber scenario objectsourceLocation
: (object
): location of step
#
afterScenarioRuns after a Cucumber Scenario.
Parameters:
uri
: (string
): path to feature filefeature
: (object
): Cucumber feature objectscenario
: (object
): Cucumber scenario objectresult
: (object
): scenario resultsourceLocation
: (object
): location of step
#
beforeStepRuns before a Cucumber Step.
Parameters:
uri
: (string
): path to feature filefeature
: (object
): Cucumber feature objectstep
: (object
): Cucumber step object
#
afterStepRuns after a Cucumber Step.
Parameters:
details
: (object
): step details (containsuri
,feature
andstep
property objects)context
: (object
): Cucumber context objectresult
(object
): step result (containserror
,result
,duration
,passed
,retries
properties)