Skip to main content

Capabilities

A capability is a definition for a remote interface. It helps WebdriverIO to understand in which browser or mobile environment you like to run your tests on. Capabilities are less crucial when developing tests locally as you run it on one remote interface most of the time but becomes more important when running a large set of integration tests in CI/CD.

info

The format of a capability object is well defined by the WebDriver specification. The WebdriverIO testrunner will fail early if user defined capabilities do not adhere to that specification.

Custom Capabilitiesโ€‹

While the amount of fixed defined capabilities is very low, everyone can provide and accept custom capabilities that are specific to the automation driver or remote interface:

Browser Specific Capability Extensionsโ€‹

  • goog:chromeOptions: Chromedriver extensions, only applicable for testing in Chrome
  • moz:firefoxOptions: Geckodriver extensions, only applicable for testing in Firefox
  • ms:edgeOptions: EdgeOptions for specifying the environment when using EdgeDriver for testing Chromium Edge

Cloud Vendor Capability Extensionsโ€‹

Automation Engine Capability Extensionsโ€‹

WebdriverIO Capabilities to manage browser driver optionsโ€‹

WebdriverIO manages installing and running browser driver for you. WebdriverIO uses a custom capability that allows you to pass in parameters to the driver.

wdio:chromedriverOptionsโ€‹

Specific options passed into Chromedriver when starting it.

wdio:geckodriverOptionsโ€‹

Specific options passed into Geckodriver when starting it.

wdio:edgedriverOptionsโ€‹

Specific options passed into Edgedriver when starting it.

wdio:safaridriverOptionsโ€‹

Specific options passed into Safari when starting it.

wdio:maxInstancesโ€‹

Type
number

Maximum number of total parallel running workers for the specific browser/capability. Takes precedence over maxInstances and maxInstancesPerCapability.

wdio:specsโ€‹

Type
(String | String[])[]

Define specs for test execution for that browser/capability. Same as the regular specs configuration option, but specific to the browser/capability. Takes precedence over specs.

wdio:excludeโ€‹

Type
String[]

Exclude specs from test execution for that browser/capability. Same as the regular exclude configuration option, but specific to the browser/capability. Excludes after the global exclude configuration option is applied.

wdio:enforceWebDriverClassicโ€‹

Type
boolean

By default, WebdriverIO attempts to establish a WebDriver Bidi session. If you don't prefer that, you can set this flag to disable this behavior.

wdio:electronVersionโ€‹

Type
string

Downloads the Chromedriver bundled with this Electron release instead of the one from Chrome for Testing, for testing an Electron app set as goog:chromeOptions.binary. If browserVersion is also set, WebdriverIO uses the Chromedriver for that version instead when the Electron release can't be downloaded or CHROMEDRIVER_CDNURL is set. Nightly versions come from electron/nightlies. The Electron service sets it for you from the app's Electron version.

{
browserName: 'chrome',
'wdio:electronVersion': '33.2.1',
// a BiDi session replaces the app's window with `data:,`
'wdio:enforceWebDriverClassic': true,
'goog:chromeOptions': {
binary: './out/my-app-darwin-arm64/my-app.app/Contents/MacOS/my-app'
}
}

Common Driver Optionsโ€‹

While all drivers offer different parameters for configuration, there are some common ones that WebdriverIO understands and uses for setting up your driver or browser:

cacheDirโ€‹
Type
string
Default
process.env.WEBDRIVER_CACHE_DIR || os.tmpdir()

The path to the root of the cache directory. This directory is used to store all drivers that are downloaded when attempting to start a session.

binaryโ€‹
Type
string

Path to a custom driver binary. If set WebdriverIO won't attempt to download a driver but will use the one provided by this path. Make sure the driver is compatible with the browser you are using.

You can provide this path via CHROMEDRIVER_PATH, GECKODRIVER_PATH or EDGEDRIVER_PATH environment variables.

caution

If the driver binary is set, WebdriverIO won't attempt to download a driver but will use the one provided by this path. Make sure the driver is compatible with the browser you are using.

Custom Driver Download Hostโ€‹

If the public driver CDNs are not reachable from your environment, e.g. because you run your tests behind a corporate proxy or mirror the drivers in an internal artifact registry, you can point the download to a custom host using the following environment variables:

  • Chrome: CHROMEDRIVER_CDNURL, defaults to https://storage.googleapis.com/chrome-for-testing-public
  • Microsoft Edge: EDGEDRIVER_CDNURL, defaults to https://msedgedriver.microsoft.com

The mirror is expected to serve the driver archives under the same paths as the original CDN, e.g. for Chrome:

CHROMEDRIVER_CDNURL=https://artifactory.company.com/chrome-for-testing npx wdio run wdio.conf.js

which resolves the driver to https://artifactory.company.com/chrome-for-testing/<buildId>/<platform>/chromedriver-<platform>.zip, where <platform> is one of linux64, linux-arm64, mac-x64, mac-arm64, win32 or win64, e.g. .../140.0.7339.207/mac-arm64/chromedriver-mac-arm64.zip.

Fully offline environments

These variables redirect the driver download only. To keep WebdriverIO from reaching the public internet at all, four more conditions have to be met:

  • A browser has to be available locally. If WebdriverIO can't find an installed Chrome or Firefox it downloads the browser too, and that download does not honor these variables. Either install the browser on the machine or point WebdriverIO at it via goog:chromeOptions.binary / moz:firefoxOptions.binary.
  • Use a full version number. If browserVersion is omitted, WebdriverIO reads the exact version from the local browser and no version lookup is needed. If you do set it, use the complete four part version, e.g. 140.0.7339.207. A release channel (stable), a milestone (140) or a partial version (140.0.7339) requires a version lookup against a public Google endpoint that can't be redirected.
  • Chromedriver has to come from Chrome for Testing. For Chrome older than 153.0.8001.0 on Linux ARM64, and with wdio:electronVersion but no browserVersion, Chromedriver is downloaded from Electron's GitHub releases, which these variables don't redirect.
  • Make sure the mirror actually has the version you need. If the driver can't be fetched from your host โ€” because the version isn't mirrored, but equally because the url is wrong or the credentials were rejected โ€” WebdriverIO logs a warning and then looks up the closest known good version, which again queries the public endpoint. Check the warning for the host it tried if a run unexpectedly reaches the internet or picks a version you didn't ask for.

Browser Specific Driver Optionsโ€‹

In order to propagate options to the driver you can use the following custom capabilities:

  • Chrome or Chromium: wdio:chromedriverOptions
  • Firefox: wdio:geckodriverOptions
  • Microsoft Egde: wdio:edgedriverOptions
  • Safari: wdio:safaridriverOptions
adbPortโ€‹
Type
number

The port on which the ADB driver should run.

Example: 9515

urlBaseโ€‹
Type
string

Base URL path prefix for commands, e.g. wd/url.

Example: /

logPathโ€‹
Type
string

Write server log to file instead of stderr, increases log level to INFO

logLevelโ€‹
Type
string

Set log level. Possible options ALL, DEBUG, INFO, WARNING, SEVERE, OFF.

verboseโ€‹
Type
boolean

Log verbosely (equivalent to --log-level=ALL)

silentโ€‹
Type
boolean

Log nothing (equivalent to --log-level=OFF)

appendLogโ€‹
Type
boolean

Append log file instead of rewriting.

replayableโ€‹
Type
boolean

Log verbosely and don't truncate long strings so that the log can be replayed (experimental).

readableTimestampโ€‹
Type
boolean

Add readable timestamps to log.

enableChromeLogsโ€‹
Type
boolean

Show logs from the browser (overrides other logging options).

bidiMapperPathโ€‹
Type
string

Custom bidi mapper path.

allowedIpsโ€‹
Type
string[]
Default
['']

Comma-separated allowlist of remote IP addresses which are allowed to connect to EdgeDriver.

allowedOriginsโ€‹
Type
string[]
Default
['*']

Comma-separated allowlist of request origins which are allowed to connect to EdgeDriver. Using * to allow any host origin is dangerous!

spawnOptsโ€‹
Type
SpawnOptionsWithoutStdio | SpawnOptionsWithStdioTuple<StdioOption, StdioOption, StdioOption>
Default
undefined

Options to be passed into the driver process.

Special Capabilities for Specific Use Casesโ€‹

This is a list of examples showing which capabilities need to be applied to achieve a certain use case.

Run Browser Headlessโ€‹

Running a headless browser means to run a browser instance without window or UI. This is mostly used within CI/CD environments where no display is used. To run a browser in headless mode, apply the following capabilities:

{
browserName: 'chrome', // or 'chromium'
'goog:chromeOptions': {
args: ['headless', 'disable-gpu']
}
}

Automate Different Browser Channelsโ€‹

If you like to test a browser version that is not yet released as stable, e.g. Chrome Canary, you can do so by setting capabilities and pointing to the browser you like to start, e.g.:

When testing on Chrome, WebdriverIO will automatically download the desired browser version and driver for you based on the defined browserVersion, e.g.:

{
browserName: 'chrome', // or 'chromium'
browserVersion: '116' // or '116.0.5845.96', 'stable', 'dev', 'canary', 'beta' or 'latest' (same as 'canary')
}

If you like to test a manually downloaded browser, you can provide a binary path to the browser via:

{
browserName: 'chrome', // or 'chromium'
'goog:chromeOptions': {
binary: '/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'
}
}

Additionally, if you like to use a manually downloaded driver, you can provide a binary path to the driver via:

{
browserName: 'chrome', // or 'chromium'
'wdio:chromedriverOptions': {
binary: '/path/to/chromdriver'
}
}

Extend Custom Capabilitiesโ€‹

If you like to define your own set of capabilities in order to e.g. store arbitrary data to be used within the tests for that specific capability, you can do so by e.g. setting:

export const config = {
// ...
capabilities: [{
browserName: 'chrome',
'custom:caps': {
// custom configurations
}
}]
}

It is advised to follow the W3C protocol when it comes to capability naming which requires a : (colon) character, denoting an implementation specific namespace. Within your tests you can access your custom capability through, e.g.:

browser.capabilities['custom:caps']

In order to ensure type safety you can extend WebdriverIOs capability interface via:

declare global {
namespace WebdriverIO {
interface Capabilities {
'custom:caps': {
// ...
}
}
}
}

Welcome! How can I help?

WebdriverIO AI Copilot