webdriverio/packages/wdio-globals
WebdriverIO Release Bot 796df04f0f v9.17.0
2025-07-09 06:16:07 +00:00
..
src chore(linter) fixed linter warnings with --fix (#14626) 2025-07-08 23:00:01 -07:00
tests implement @wdio/globals into @wdio/runner 2022-08-09 09:06:54 +02:00
.npmignore breaking(build): migrate to Esbuild for bundling (#13338) 2024-08-08 23:47:30 -07:00
LICENSE fix(docs): change file name of license from LICENSE-MIT to just LICENSE 2024-08-05 11:24:13 -07:00
package.json v9.17.0 2025-07-09 06:16:07 +00:00
README.md Bump depcheck from 1.4.3 to 1.4.5 (#11036) 2023-09-12 09:08:00 +02:00
tsconfig.json implement @wdio/globals into @wdio/runner 2022-08-09 09:06:54 +02:00
types.d.ts @wdio/globals: Declare "expect" global type explicitly (#12499) 2024-03-21 16:51:22 -07:00

WDIO Globals

A helper utility for importing global variables directly

In your test files, WebdriverIO puts each of these methods and objects into the global environment. You don't have to import anything to use them. However, if you prefer explicit imports, you can do import { browser, $, $$, expect } from '@wdio/globals' and set injectGlobals: false in your WDIO configuration.

The following global objects are set if not configured otherwise:

  • browser: WebdriverIO Browser object
  • driver: alias to browser (used when running mobile tests)
  • multiremotebrowser: alias to browser or driver but only set for Multiremote sessions
  • $: command to fetch an element (see more in API docs)
  • $$: command to fetch elements (see more in API docs)
  • expect: assertion framework for WebdriverIO (see API docs)

Note: WebdriverIO has no control of used frameworks (e.g. Mocha or Jasmine) setting global variables when bootstrapping their environment.

Install

To install the package, run:

npm i @wdio/globals --save-dev

Usage

You can implicitly import WebdriverIO primitives as following:

import { browser, $, $$, expect } from '@wdio/globals'

describe('my test', () => {
    // ...

    it('can do something', async () => {
        // ...
    })

    // ...
})

TypeScript

If you have a TypeScript project you can propagate the WebdriverIO namespace by adding this package to the types list, e.g.:

{
    "compilerOptions": {
        "types": ["node", "@wdio/globals/types"]
    }
}

For more information on WebdriverIO Globals, check out the docs.