Skip to main content

wdio session

wdio session keeps one WebdriverIO session alive across many short shell commands. Use it to explore a UI, check a change, and turn the steps that worked into a test. It is part of @wdio/cli (WebdriverIO v10).

npx wdio session open chrome http://localhost:3000
npx wdio session snapshot --interactive
npx wdio session click e3
npx wdio session export --out test/specs/cart.e2e.ts
npx wdio session close

The session is named default. Pass -s <name> only when you need two sessions at once.

Install​

wdio session is part of the WebdriverIO CLI. npx wdio installs the unscoped wdio package and runs that CLI. You do not install @wdio/session yourself.

npx wdio session --help

Scaffold a project with:

npm init wdio@latest

Accept "Set up coding agent support" to write .agents/skills/wdio-session/SKILL.md, an AGENTS.md section and a .wdio/session/ gitignore entry. Install the skill later with:

npx wdio session skill --install .

npx wdio session doctor checks Node.js, the browser, Appium, SDKs and cloud credentials. doctor <target> checks only what that target needs. The process exits 1 when a check fails.

Open a page and act on it​

Open headless Chrome (add --headed to show the window) and read the page before clicking:

npx wdio session open chrome http://localhost:3000
npx wdio session snapshot --interactive

A snapshot line looks like button "Add to cart" [ref=e3]. Use that ref:

npx wdio session click e3
npx wdio session exec -e "await expect($('aria/Cart (1)')).toBeDisplayed()"

Then save the steps and stop the session:

npx wdio session export --out test/specs/cart.e2e.ts
npx wdio run wdio.conf.ts --spec test/specs/cart.e2e.ts
npx wdio session close

open firefox, open edge and open safari take the same URL. Other targets, snapshots, exec, export and a paused test run are separate pages in this section.

This section​

PageUse it for
TargetsBrowsers, Android, iOS, desktop, Electron, Tauri, Dioxus and cloud devices
Snapshots and refsWhat is on screen, and the refs you click
Run codeexec, assertions and visual checks
Export a testSpecs, page objects and .wdio/helpers
Debug a testwdio run --debug=agent and wdio repl --session
CommandsEvery action and flag

Troubleshooting​

MessageWhat to do
SESSION_EXISTSThe name is already running. Use -s another name, or open --replace.
REF_STALE / REF_NOT_FOUNDRun snapshot again and use a ref from that output.
MISSING_DEPENDENCYInstall the package named in the error, or run wdio session doctor <target>.
MISSING_APPIUM_DRIVERRun the npx appium driver install … line from the error.
MISSING_CREDENTIALSExport the named variables. Doctor never prints their values.
Session closed from wdio sessionThe debug session was closed. Resume instead of close when the test should continue.

Exit codes: 0 success, 1 the action failed, 2 usage, 3 a missing dependency or credentials, 4 no session with that name.

Next steps​

Welcome! How can I help?

WebdriverIO AI Copilot