# WebdriverIO v10 documentation: Debugging > 25 pages. Index of all sections: https://webdriver.io/llms.txt --- Source: https://webdriver.io/docs/debugging.md # Debugging Debugging is significantly more difficult when several processes spawn dozens of tests in multiple browsers. For starters, it is extremely helpful to limit parallelism by setting `maxInstances` to `1`, and targeting only those specs and browsers that need to be debugged. In `wdio.conf`: ``` export const config = { // ... maxInstances: 1, specs: [ '**/myspec.spec.js' ], capabilities: [{ browserName: 'firefox' }], // ... } ``` ## The Debug Command[​](#the-debug-command "Direct link to The Debug Command") In many cases, you can use [`browser.debug()`](/docs/api/browser/debug.md) to pause your test and inspect the browser. Your command line interface will also switch into REPL mode. This mode allows you to fiddle around with commands and elements on the page. In REPL mode, you can access the `browser` object—or `$` and `$$` functions—like you can in your tests. When using `browser.debug()`, you will likely need to increase the timeout of the test runner to prevent the test runner from failing the test for taking to long. For example: In `wdio.conf`: ``` jasmineOpts: { defaultTimeoutInterval: (24 * 60 * 60 * 1000) } ``` See [timeouts](/docs/timeouts.md) for more information on how to do that using other frameworks. To proceed with the tests after debugging, in the shell use `^C` shortcut or the `.exit` command. ### Pause for a coding agent (`--debug=agent`)[​](#pause-for-a-coding-agent---debugagent "Direct link to pause-for-a-coding-agent---debugagent") `wdio run --debug=agent` raises the framework timeout to 24 hours and pauses the worker when a spec calls `await browser.debug()` or when a test fails. The run prints a line like: ``` Paused in cart.e2e.ts › adds a blue t-shirt. Inspect with `wdio session -s debug-0-0 snapshot`, continue with `wdio session -s debug-0-0 resume`. ``` Inspect the paused browser with [`wdio session`](/docs/session/debug.md) (`snapshot`, `exec`, …), then `wdio session -s debug-0-0 resume` to continue. `wdio session -s debug-0-0 close` fails the paused test with `Session closed from wdio session`. The session name is `debug-` (`debug-0-0` for the first worker). The rest of that workflow is in the [WebdriverIO Session](/docs/session.md) section. ## Dynamic configuration[​](#dynamic-configuration "Direct link to Dynamic configuration") Note that `wdio.conf.js` can contain Javascript. Since you probably do not want to permanently change your timeout value to 1 day, it can be often helpful to change these settings from the command line using an environment variable. Using this technique, you can dynamically change the configuration: ``` const debug = process.env.DEBUG const defaultCapabilities = ... const defaultTimeoutInterval = ... const defaultSpecs = ... export const config = { // ... maxInstances: debug ? 1 : 100, capabilities: debug ? [{ browserName: 'chrome' }] : defaultCapabilities, execArgv: debug ? ['--inspect'] : [], jasmineOpts: { defaultTimeoutInterval: debug ? (24 * 60 * 60 * 1000) : defaultTimeoutInterval } // ... } ``` You can then prefix the `wdio` command with the `debug` flag: ``` $ DEBUG=true npx wdio wdio.conf.js --spec ./tests/e2e/myspec.test.js ``` ...and debug your spec file with the DevTools! ## Debugging with Visual Studio Code (VSCode)[​](#debugging-with-visual-studio-code-vscode "Direct link to Debugging with Visual Studio Code (VSCode)") If you want to debug your tests with breakpoints in latest VSCode, you have two options for starting the debugger of which option 1 is the easiest method: 1. automatically attaching the debugger 2. attaching the debugger using a configuration file ### VSCode Toggle Auto Attach[​](#vscode-toggle-auto-attach "Direct link to VSCode Toggle Auto Attach") You can automatically attach the debugger by following these steps in VSCode: * Press CMD + Shift + P (Linux and Macos) or CTRL + Shift + P (Windows) * Type "attach" into the input field * Select "Debug: Toggle Auto Attach" * Select "Only With Flag" That's it! Now when you run your tests (remember you will need the --inspect flag set in your config as shown earlier) it will automatically start the debugger and stop on the first breakpoint that it reaches. ### VSCode Configuration file[​](#vscode-configuration-file "Direct link to VSCode Configuration file") It's possible to run all or selected spec file(s). Debug configuration(s) have to be added to `.vscode/launch.json`, to debug selected spec add the following config: ``` { "name": "run select spec", "type": "node", "request": "launch", "args": ["wdio.conf.js", "--spec", "${file}"], "cwd": "${workspaceFolder}", "autoAttachChildProcesses": true, "program": "${workspaceRoot}/node_modules/@wdio/cli/bin/wdio.js", "console": "integratedTerminal", "skipFiles": [ "${workspaceFolder}/node_modules/**/*.js", "${workspaceFolder}/lib/**/*.js", "/**/*.js" ] }, ``` To run all spec files remove `"--spec", "${file}"` from `"args"` Example: [.vscode/launch.json](https://github.com/mgrybyk/webdriverio-devtools/blob/master/.vscode/launch.json) Additional info: ## Dynamic Repl with Atom[​](#dynamic-repl-with-atom "Direct link to Dynamic Repl with Atom") If you are an [Atom](https://atom.io/) hacker you can try [`wdio-repl`](https://github.com/kurtharriger/wdio-repl) by [@kurtharriger](https://github.com/kurtharriger) which is a dynamic repl that allows you to execute single code lines in Atom. Watch [this](https://www.youtube.com/watch?v=kdM05ChhLQE) YouTube video to see a demo. ## Debugging with WebStorm / Intellij[​](#debugging-with-webstorm--intellij "Direct link to Debugging with WebStorm / Intellij") You can create a node.js debug configuration like this: ![Screenshot from 2021-05-29 17-33-33](https://user-images.githubusercontent.com/18728354/120088460-81844c00-c0a5-11eb-916b-50f21c8472a8.png) Watch this [YouTube Video](https://www.youtube.com/watch?v=Qcqnmle6Wu8) for more information about how to make a configuration. ## Debugging flaky tests[​](#debugging-flaky-tests "Direct link to Debugging flaky tests") Flaky tests can be really hard to debug so here are some tips how you can try and get that flaky result you got in your CI, reproduced locally. ### Network[​](#network "Direct link to Network") To debug network related flakiness use the [throttleNetwork](https://webdriver.io/docs/api/browser/throttleNetwork) command. ``` await browser.throttleNetwork('Regular3G') ``` ### Rendering speed[​](#rendering-speed "Direct link to Rendering speed") To debug device speed related flakiness use the [throttleCPU](https://webdriver.io/docs/api/browser/throttleCPU) command. This will cause your pages to render slower which can be caused by many things like running multiple processes in your CI which could be slowing down your tests. ``` await browser.throttleCPU(4) ``` ### Test execution speed[​](#test-execution-speed "Direct link to Test execution speed") If your tests do not seem to be affected it is possible that WebdriverIO is faster than the update from the frontend framework / browser. This happens when using synchronous assertions since WebdriverIO has no chance to retry these assertions anymore. Some examples of code that can break because of this: ``` expect(elementList.length).toEqual(7) // list might not be populated at the time of the assertion expect(await elem.getText()).toEqual('this button was clicked 3 times') // text might not be updated yet at the time of assertion resulting in an error ("this button was clicked 2 times" does not match the expected "this button was clicked 3 times") expect(await elem.isDisplayed()).toBe(true) // might not be displayed yet ``` To resolve this problem, asynchronous assertions should be used instead. The above examples would looks like this: ``` await expect(elementList).toBeElementsArrayOfSize(7) await expect(elem).toHaveText('this button was clicked 3 times') await expect(elem).toBeDisplayed() ``` Using these assertions, WebdriverIO will automatically wait until the condition matches. When asserting text this means that the element needs to exist and the text needs to be equal to the expected value. We talk more about this in our [Best Practices Guide](https://webdriver.io/docs/bestpractices#use-the-built-in-assertions). ## Performance Profiling[​](#performance-profiling "Direct link to Performance Profiling") WebdriverIO allows you to capture performance profiles of your tests to identify bottlenecks in your test execution or memory leaks. This uses Node.js native profiling capabilities. ### CPU Profiling[​](#cpu-profiling "Direct link to CPU Profiling") To capture a CPU profile, you can use the `--cpu-prof` CLI flag or set `cpuProf: true` in your configuration. ``` npx wdio run wdio.conf.js --cpu-prof ``` This will generate a `.cpuprofile` file in the `./profiles` directory (default) for each worker process. You can load this file into **Chrome DevTools > Performance > Load Profile** to analyze the execution. ### Heap Profiling[​](#heap-profiling "Direct link to Heap Profiling") To capture a Heap profile, use the `--heap-prof` CLI flag or set `heapProf: true` in your configuration. ``` npx wdio run wdio.conf.js --heap-prof ``` This generates a `.heapprofile` file in the `./profiles` directory (uses sampling heap profiler). You can load this into **Chrome DevTools > Memory > Load** to analyze memory usage. ### Timing Metrics[​](#timing-metrics "Direct link to Timing Metrics") When profiling is enabled, WebdriverIO also automatically logs timing metrics for the setup, execution, and teardown phases of your test, helping you understand where time is being spent. ``` 📊 Performance Metrics: ──────────────────────────────────────── Setup: 1.25s Execution: 3.42s Teardown: 0.15s ``` --- Source: https://webdriver.io/docs/repl.md # REPL interface With `v4.5.0`, WebdriverIO introduced a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) interface that helps you to not only learn the framework API, but also debug and inspect your tests. It can be used in multiple ways. First you can use it as CLI command by installing `npm install -g @wdio/cli` and spawn a WebDriver session from the command line, e.g. ``` wdio repl chrome ``` This would open a Chrome browser that you can control with the REPL interface. Make sure you have a browser driver running on port `4444` in order to initiate the session. If you have a [Sauce Labs](https://saucelabs.com) (or other cloud vendor) account, you can also directly run the browser on your command line in the cloud via: ``` wdio repl chrome -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY ``` If driver is running on different port eg : 9515, it could passed with the command line argument --port or alias -p ``` wdio repl chrome -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY -p 9515 ``` Repl could also be ran using the capabilities from the webdriverIO config file. Wdio supports capabilities object; or ; multi-remote capability list or object. If the config file uses capabilities object then just pass the path to config file, else if its a multi-remote capability then, specify which capability to use from list or multi-remote using the positional argument . Note: for list we consider zero based index. ### Example[​](#example "Direct link to Example") WebdriverIO with capability array: wdio.conf.ts example ``` export const config = { // ... capabilities:[{ browserName: 'chrome', // options: `chrome`, `edge`, `firefox`, `safari`, `chromium` browserVersion: '27.0', // browser version platformName: 'Windows 10' // OS platform }] } ``` ``` wdio repl "./path/to/wdio.config.js" 0 -p 9515 ``` WebdriverIO with [multi-remote](https://webdriver.io/docs/multiremote/) capability object: wdio.conf.ts example ``` export const config = { // ... capabilities: { myChromeBrowser: { capabilities: { browserName: 'chrome' } }, myFirefoxBrowser: { capabilities: { browserName: 'firefox' } } } } ``` ``` wdio repl "./path/to/wdio.config.js" "myChromeBrowser" -p 9515 ``` Or if you want to run local mobile tests using Appium: * Android * iOS ``` wdio repl android ``` ``` wdio repl ios ``` This would open Chrome/Safari session on connected device/emulator/simulator. Make sure Appium running on port `4444` in order to initiate the session. ``` wdio repl './path/to/your_app.apk' ``` This would open App session on connected device/emulator/simulator. Make sure Appium running on port `4444` in order to initiate the session. Capabilities for iOS device can be passed with arguments: * `-v` - `platformVersion`: version of Android/iOS platform * `-d` - `deviceName`: name of mobile device * `-u` - `udid`: udid for real devices Usage: * Long Parameter Names * Short Parameter Names ``` wdio repl ios --platformVersion 11.3 --deviceName 'iPhone 7' --udid 123432abc ``` ``` wdio repl ios -v 11.3 -d 'iPhone 7' -u 123432abc ``` You can apply any options (see `wdio repl --help`) available for your REPL session. ### Attach to a `wdio session`[​](#attach-to-a-wdio-session "Direct link to attach-to-a-wdio-session") `wdio repl --session ` (alias `-s`) does not start a browser. It attaches the REPL to a session that [`wdio session`](/docs/session.md) already opened, and detaching leaves that session running. Pausing a test run is covered in [Debug a test with a session](/docs/session/debug.md): ``` npx wdio session open chrome https://webdriver.io npx wdio repl --session default ``` In the REPL, each line runs as `wdio session exec`. `.exit` prints `Detached from "default" (still running)`. ![WebdriverIO REPL](https://webdriver.io/img/repl.gif) Another way to use the REPL is in inside your tests via the [`debug`](/docs/api/browser/debug.md) command. This will stop the browser when called, and enables you to jump into the application (e.g. to the dev tools) or control the browser from the command line. This is helpful when some commands don't trigger a certain action as expected. With the REPL, you can then try out the commands to see which are working most reliably. --- Source: https://webdriver.io/docs/record.md # Record Tests Chrome DevTools has a *Recorder* panel that allows users to record and playback automated steps within Chrome. These steps can be [exported into WebdriverIO tests with an extension](https://chrome.google.com/webstore/detail/webdriverio-chrome-record/pllimkccefnbmghgcikpjkmmcadeddfn?hl=en) making writing test very easy. ## What is Chrome DevTools Recorder[​](#what-is-chrome-devtools-recorder "Direct link to What is Chrome DevTools Recorder") The [Chrome DevTools Recorder](https://developer.chrome.com/docs/devtools/recorder/) is a tool which allows you to record and replay test actions directly in the browser and also export them as JSON (or export them in e2e test), as well as measure test performance. The tool is straightforward, and since it’s plugged into the browser, we have the convenience of not switching the context or dealing with any third-party tool. ## How to Record a Test with Chrome DevTools Recorder[​](#how-to-record-a-test-with-chrome-devtools-recorder "Direct link to How to Record a Test with Chrome DevTools Recorder") If you have the latest Chrome you will have the Recorder already installed and available for you. Just open any website, do a Right-Click and select *"Inspect"*. Within DevTools you can open the Recorder by pressing `CMD/Control` + `Shift` + `p` and enter *"Show Recorder"*. ![Chrome DevTools Recorder](/assets/images/recorder-f894538ca948dd941657c62dacd05913.png) To start recording a user journey, click on *"Start new recording"*, give your test a name and then use the browser to record your test: ![Chrome DevTools Recorder](/assets/images/demo-6d88b7908b9f6ebbd242549e55864ca9.gif) Next step, click on *"Replay"* to check if the recording was successful and does what you wanted to do. If everything is ok, click on the [export](https://developer.chrome.com/docs/devtools/recorder/reference/#recorder-extension) icon and select *"Export as a WebdriverIO Test Script"*: The *"Export as a WebdriverIO Test Script"* option only available if you install the [WebdriverIO Chrome Recorder](https://chrome.google.com/webstore/detail/webdriverio-chrome-record/pllimkccefnbmghgcikpjkmmcadeddfn) extension. ![Chrome DevTools Recorder](/assets/images/export-68a6339fc1b891e53607f6552b4588db.gif) That's it! ## Export Recording[​](#export-recording "Direct link to Export Recording") If you exported the flow as WebdriverIO test script, it should download script that you can copy\&paste in your test suite. For example the above recording looks as follows: ``` describe("My WebdriverIO Test", function () { it("tests My WebdriverIO Test", function () { await browser.setWindowSize(1026, 688) await browser.url("https://webdriver.io/") await browser.$("#__docusaurus > div.main-wrapper > header > div").click() await browser.$("#__docusaurus > nav > div.navbar__inner > div:nth-child(1) > a:nth-child(3)").click()rec await browser.$("#__docusaurus > div.main-wrapper.docs-wrapper.docs-doc-page > div > aside > div > nav > ul > li:nth-child(4) > div > a").click() await browser.$("#__docusaurus > div.main-wrapper.docs-wrapper.docs-doc-page > div > aside > div > nav > ul > li:nth-child(4) > ul > li:nth-child(2) > a").click() await browser.$("#__docusaurus > nav > div.navbar__inner > div.navbar__items.navbar__items--right > div.searchBox_qEbK > button > span.DocSearch-Button-Container > span").click() await browser.$("#docsearch-input").setValue("click") await browser.$("#docsearch-item-0 > a > div > div.DocSearch-Hit-content-wrapper > span").click() }); }); ``` Make sure you revisit some of the locators and replace them with more resilient [selector types](/docs/selectors.md) one if necessary. You can also export the flow as JSON file and use the [`@wdio/chrome-recorder`](https://github.com/webdriverio/chrome-recorder) package to transform it into an actual test script. ## Next Steps[​](#next-steps "Direct link to Next Steps") You can use this flow to easily create tests for your applications. The Chrome DevTools Recorder has various additional features, e.g.: * [Simulate slow network](https://developer.chrome.com/docs/devtools/recorder/#simulate-slow-network) or * [Measure performance of your tests](https://developer.chrome.com/docs/devtools/recorder/#measure) Make sure to check out their [docs](https://developer.chrome.com/docs/devtools/recorder). --- Source: https://webdriver.io/docs/autocompletion.md # Autocompletion ## IntelliJ[​](#intellij "Direct link to IntelliJ") Autocompletion works out of the box in IDEA and WebStorm. If you have been writing program code for a while, you probably like autocompletion. Autocomplete is available out of the box in many code editors. ![Autocompletion](/assets/images/0-4587a8e32bf6e92c57be8bb5647750e1.png) Type definitions based on [JSDoc](http://usejsdoc.org/) is used for documenting code. It helps to see more additional details about parameters and their types. ![Autocompletion](/assets/images/1-dcfd0160c6fddbf751926e0cd8065525.png) Use standard shortcuts `⇧ + ⌥ + SPACE` on IntelliJ Platform to see available documentation: ![Autocompletion](/assets/images/2-b565f727863ad47479badfa1b7264c72.png) ## Visual Studio Code (VSCode)[​](#visual-studio-code-vscode "Direct link to Visual Studio Code (VSCode)") Visual Studio Code usually has type support automatically integrated and there is no action needed. ![Autocompletion](/assets/images/14-e1c7f7d906a37ff538be69b889461592.png) If you use vanilla JavaScript and want to have proper type support you have to create a `jsconfig.json` in your project root and refer to used wdio packages, e.g.: jsconfig.json ``` { "compilerOptions": { "types": [ "node", "@wdio/globals/types", "@wdio/mocha-framework" ] } } ``` --- Source: https://webdriver.io/docs/devtools.md # DevTools DevTools is a powerful browser-based debugging interface for visualizing, controlling, and inspecting your test executions in real-time. It works with **WebdriverIO**, **Nightwatch.js**, **Selenium WebDriver** (any runner) and **Python Selenium** — same backend, same UI, same capture infrastructure. ## What It Provides[​](#what-it-provides "Direct link to What It Provides") * **Rerun tests selectively** - Click on any test case or suite to re-execute it instantly ([details](/docs/devtools/wdio/interactive-test-rerunning.md)) * **Preserve & Rerun (Compare)** - Snapshot a failing test, rerun it, and diff the two runs side-by-side aligned by command ([details](/docs/devtools/wdio/preserve-and-rerun.md)) * **Debug visually** - See live browser previews with automatic screenshots after each command * **Track execution** - View detailed command logs with timestamps and results * **Monitor network & console** - Inspect API calls and JavaScript logs ([network](/docs/devtools/wdio/network-logs.md) · [console](/docs/devtools/wdio/console-logs.md)) * **Navigate to code** - Jump directly to test source files with TestLens ([details](/docs/devtools/wdio/testlens.md)) * **Record sessions** - Continuous `.webm` video of the browser, per session ([details](/docs/devtools/wdio/screencast.md)) * **Mobile** - Appium sessions (mobile browser, native and hybrid apps) in live and trace mode ([details](/docs/devtools/mobile.md)) * **Trace mode** - Headless capture path producing a portable `trace.zip` artifact for offline replay or agentic consumption ([details](/docs/devtools/wdio/trace-mode.md)) ## How It Works[​](#how-it-works "Direct link to How It Works") 1. Start your tests as normal 2. DevTools automatically opens a browser window at `http://localhost:3000` 3. The UI shows test hierarchy, browser preview, command timeline, and logs in real-time 4. After tests complete, click any test to rerun it; the rerun runs in a fresh test process and streams into the same dashboard window ## Choose Your Framework[​](#choose-your-framework "Direct link to Choose Your Framework") * **[WebDriverIO](/docs/devtools/wdio.md)** - Use `@wdio/devtools-service` with Mocha, Jasmine, or Cucumber * **[Nightwatch](/docs/devtools/nightwatch.md)** - Use `@wdio/nightwatch-devtools` with zero test code changes * **[Selenium](/docs/devtools/selenium.md)** - Use `@wdio/selenium-devtools` with Mocha, Jest, Cucumber, or plain Node scripts * **[Python Selenium](/docs/devtools/selenium.md)** - Use `selenium-devtools-py` under pytest or a plain script (see the Python tabs) --- Source: https://webdriver.io/docs/devtools/getting-started.md # Getting Started WebdriverIO DevTools gives your end-to-end browser tests a developer-tools UI for running, debugging, and inspecting automation — DOM replay, per-command screenshots, network and console capture, and session screencasts. It runs in two modes. **Live mode** opens an interactive [dashboard](/docs/devtools/dashboard.md) in a browser window while your tests execute, so you can watch and rerun them in real time. **Trace mode** skips the UI and writes a portable, offline [trace artifact](/docs/devtools/wdio/trace-mode.md) (`trace.zip`) you can open later in the `show-trace` player — ideal for CI. This page gets you into live mode fast; trace mode is one option away. ## Install & first run[​](#install--first-run "Direct link to Install & first run") Pick your adapter, install it, and add the minimal wiring below. Run your tests as usual — the DevTools dashboard opens automatically in a new browser window. * WebdriverIO * Selenium * Nightwatch * Python Install the service: ``` npm install @wdio/devtools-service --save-dev ``` Add it to your test-runner config: ``` // wdio.conf.ts export const config = { services: ['devtools'], } ``` Run your WebdriverIO tests as normal — the DevTools UI opens automatically and tests begin visualizing immediately. Works with Mocha, Jest, Cucumber, or a plain `node` script — the plugin auto-detects the runner. Install it: ``` npm install @wdio/selenium-devtools ``` Add a single import and one `configure` call at the top of your test file (Mocha shown): ``` // tests/example.test.js import { Builder, By, until } from 'selenium-webdriver' import { DevTools } from '@wdio/selenium-devtools' DevTools.configure({ screencast: { enabled: true, quality: 70, maxWidth: 1280, maxHeight: 720 } }) describe('smoke test', function () { let driver before(async function () { driver = await new Builder().forBrowser('chrome').build() }) after(async function () { if (driver) { await driver.quit() } }) it('loads example.com', async function () { await driver.get('https://example.com') await driver.wait(until.elementLocated(By.css('h1')), 10000) }) }) ``` Run it — the DevTools UI opens in a new Chrome window: ``` mocha --timeout 60000 tests/example.test.js ``` See the [Selenium page](/docs/devtools/selenium.md) for the Jest, Cucumber, and plain-Node setups. Install the adapter: ``` npm install @wdio/nightwatch-devtools ``` Wire it into your Nightwatch config via `globals` — no test-file changes needed: ``` // nightwatch.conf.cjs const nightwatchDevtools = require('@wdio/nightwatch-devtools').default module.exports = { src_folders: ['tests'], test_settings: { default: { desiredCapabilities: { browserName: 'chrome', // Required for network request capture 'goog:loggingPrefs': { performance: 'ALL' } }, globals: nightwatchDevtools({ port: 3000 }) } } } ``` Run your tests as normal — the DevTools UI opens automatically: ``` nightwatch ``` See the [Nightwatch page](/docs/devtools/nightwatch.md) for the Cucumber/BDD setup. Needs Python 3.10+, `selenium>=4.44`, and Node.js 22.23.4+, 24.22.1+ or 26.12.1+ on `PATH` (the dashboard backend is a Node application). Install the adapter, then the backend once: ``` pip install selenium-devtools-py selenium-devtools install-backend ``` Under pytest nothing goes in your test files. Turn capture on with a flag: ``` pytest --devtools tests/ # live dashboard pytest --devtools-trace tests/ # write a trace archive instead ``` See the Python tabs on the [Selenium page](/docs/devtools/selenium.md) for plain scripts, ini options and environment variables. ## Next steps[​](#next-steps "Direct link to Next steps") * **[Trace Mode](/docs/devtools/wdio/trace-mode.md)** — set `mode: 'trace'` to skip the UI and produce a portable, offline trace artifact for CI. * **[Configuration Reference](/docs/devtools/reference.md)**: every option across the adapters. * **[Mobile Testing](/docs/devtools/mobile.md)**: capture Appium sessions. * **Frameworks** — full per-adapter guides: [WebdriverIO](/docs/devtools/wdio.md), [Selenium](/docs/devtools/selenium.md), [Nightwatch](/docs/devtools/nightwatch.md). --- Source: https://webdriver.io/docs/devtools/reference.md # Configuration Reference All DevTools options at a glance, across the three adapters. Shared options have the same **names, types and defaults** on every adapter; where behaviour or availability differs, it's noted, and adapter-only options are listed separately. The Python adapter takes no options object; see the Python tabs on the [Selenium](/docs/devtools/selenium.md#configuration-options) page. For the full explanation of each trace option see the linked section on the [Trace Mode](/docs/devtools/wdio/trace-mode.md) page. Pass options the way each adapter takes them: * **WebdriverIO** — `services: [['devtools', { … }]]` * **Selenium** — `DevTools.configure({ … })` * **Nightwatch** — `globals: nightwatchDevtools({ … })` ## Mode & live-mode options[​](#mode--live-mode-options "Direct link to Mode & live-mode options") | Option | Type / values | Default | Notes | | ---------------------- | ------------------- | ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `mode` | `'live' \| 'trace'` | `'live'` | `'live'` opens the DevTools UI dashboard; `'trace'` skips it and writes a portable artifact. The two are mutually exclusive. | | `port` | `number` | `3000` (a free port is used if it is taken) | Port the DevTools UI / backend binds to. Live mode only. | | `hostname` | `string` | `'localhost'` | Hostname the server binds to. Live mode only. | | `screencast` | `ScreencastOptions` | `{ enabled: false }` | Continuous session video (`.webm`). Live mode only — for trace mode use `video`. Includes `maxBufferFrames` (default `2000`), the cap on frames held in memory. See [Screencast](/docs/devtools/wdio/screencast.md). | | `devtoolsCapabilities` | `Capabilities` | Chrome 1600×1200 | Capabilities used to open the DevTools UI window. WebdriverIO, live mode only. | ## Trace-mode options[​](#trace-mode-options "Direct link to Trace-mode options") Only apply when `mode: 'trace'`. | Option | Type / values | Default | Details | | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `traceFormat` | `'zip' \| 'ndjson-directory'` | `'zip'` | Single archive vs. an unpacked directory. [Output format](/docs/devtools/wdio/trace-mode.md#output-format--traceformat) | | `traceGranularity` | `'session' \| 'spec' \| 'test'` | `'session'` | One trace per session / spec file / test. `'test'` is required for per-test screenshot/video and inline Allure attach. [Trace granularity](/docs/devtools/wdio/trace-mode.md#trace-granularity--tracegranularity) | | `tracePolicy` | `'on' \| 'retain-on-failure' \| 'retain-on-first-failure' \| 'on-first-retry' \| 'on-all-retries' \| 'retain-on-failure-and-retries'` | `'on'` | Which traces to keep. Pairs with `traceGranularity: 'test'`. [Retention](/docs/devtools/wdio/trace-mode.md#retention--tracepolicy) | | `filmstrip` | `boolean` | `true` | Dense, continuous screencast into the trace for smooth scrubbing; `false` records one frame per action. Thinned at export to frames at least 100 ms apart, about 600 at most. [Dense filmstrip](/docs/devtools/wdio/trace-mode.md#dense-filmstrip--filmstrip) | | `screenshot` | `'off' \| 'on' \| 'only-on-failure'` | `'off'` | Per-test screenshot (needs `traceGranularity: 'test'`). Attached inline to Allure on WebdriverIO and Selenium; produce-only on Nightwatch. [Per-test screenshot & video](/docs/devtools/wdio/trace-mode.md#per-test-screenshot--video--screenshot--video) | | `video` | `'off' \| ` | `'off'` | Per-test video slice (needs `traceGranularity: 'test'`; encoding needs `ffmpeg` on `PATH`). Attached inline to Allure on WebdriverIO and Selenium; produce-only on Nightwatch. [Per-test screenshot & video](/docs/devtools/wdio/trace-mode.md#per-test-screenshot--video--screenshot--video) | | `emitArtifactsManifest` | `boolean` | `false` | Write `devtools-artifacts-.json`. Auto-enabled when an Allure reporter is detected (opt-in on Nightwatch). [Artifacts manifest](/docs/devtools/wdio/trace-mode.md#artifacts-manifest--emitartifactsmanifest) | | `captureAssertions` | `boolean` | `true` | Capture `node:assert` (and framework `expect` matchers where supported) as trace actions. [Assertions](/docs/devtools/wdio/trace-mode.md#assertions--captureassertions) | ## Selenium-only (Node.js)[​](#selenium-only-nodejs "Direct link to Selenium-only (Node.js)") | Option | Type / values | Default | Notes | | -------------- | ------------- | ------- | ------------------------------------------------------------------------------------------------------------------ | | `openUi` | `boolean` | `true` | Open the dashboard window automatically. Set `false` for CI. | | `headless` | `boolean` | `false` | Run the test browser headless (`--headless=old`). The dashboard window is unaffected. | | `rerunCommand` | `string` | auto | Command template for a per-test rerun; `{{testName}}` is substituted. Derived from the runner's argv when omitted. | ## Nightwatch-only[​](#nightwatch-only "Direct link to Nightwatch-only") | Option | Type / values | Default | Notes | | ------ | ------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `bidi` | `boolean` | `false` | Opt into WebDriver BiDi capture (console + JS exceptions + network). Requires `webSocketUrl: true` in capabilities. On WebdriverIO and Selenium, BiDi is auto-attached. See [Nightwatch → BiDi capture](/docs/devtools/nightwatch.md#bidi-capture-opt-in). | ## Per-adapter differences[​](#per-adapter-differences "Direct link to Per-adapter differences") Some trace capabilities degrade on certain adapters — see the [cross-framework support matrix](/docs/devtools/cross-framework.md) for the full picture. The notable ones: * **Nightwatch retry-aware retention** — only `retain-on-failure` is reliable; other `tracePolicy` values degrade to it. * **Nightwatch BDD `describe/it`** — `traceGranularity: 'test'` collapses to one session-scoped slice. * **Nightwatch Allure attach** — per-test `screenshot`/`video` are produce-only (files + manifest), not attached inline. --- Source: https://webdriver.io/docs/devtools/dashboard.md # The Dashboard Live mode opens the DevTools UI in an external browser window and streams your test run in real time. It's the interactive counterpart to [Trace Mode](/docs/devtools/wdio/trace-mode.md), which skips the UI and writes a portable offline artifact instead. Live mode is enabled by default (`mode: 'live'`), so simply running your WebdriverIO tests launches the dashboard. When you run your tests, the DevTools UI automatically opens in an external browser window and tests begin executing immediately with real-time visualization. After the initial run completes, use the play buttons to rerun individual tests or suites, and the stop button to terminate running tests at any time. ## What the dashboard shows[​](#what-the-dashboard-shows "Direct link to What the dashboard shows") * **Live browser preview** — watch the browser under test as commands execute. * **Test progress** — suites and tests update as they run. * **Command execution** — each action streams in as it happens. A wait appears as soon as it starts, as one row with the commands its condition issues nested under it; see [Waits](/docs/devtools/wdio/trace-mode.md#waits). * **Workbench tabs** — Actions and Metadata, plus Source, Log, Console, Network and Errors (each badged with a count), and Compare after a [Preserve & Rerun](/docs/devtools/wdio/preserve-and-rerun.md). ## Live-mode features[​](#live-mode-features "Direct link to Live-mode features") * **[Interactive Test Rerunning & Visualization](/docs/devtools/wdio/interactive-test-rerunning.md)** — Real-time browser previews with test rerunning * **[Preserve & Rerun (Compare)](/docs/devtools/wdio/preserve-and-rerun.md)** — Snapshot a failing test, rerun it, and diff the two runs side-by-side * **[Console Logs](/docs/devtools/wdio/console-logs.md)** — Capture and inspect browser console output * **[Network Logs](/docs/devtools/wdio/network-logs.md)** — Monitor API calls and network activity * **[Metadata](/docs/devtools/wdio/metadata.md)** — Session capabilities, environment, and timing per browser session * **[TestLens](/docs/devtools/wdio/testlens.md)** — Navigate to source code with intelligent code navigation * **[Multi-Framework Support](/docs/devtools/wdio/multi-framework-support.md)** — Works with Mocha, Jasmine, and Cucumber * **[Session Screencast](/docs/devtools/wdio/screencast.md)** — Automatic video recording of browser sessions ## Configuring the dashboard window[​](#configuring-the-dashboard-window "Direct link to Configuring the dashboard window") The `port`, `hostname`, and `devtoolsCapabilities` options control the DevTools UI server and the window it opens in. See the [Configuration Reference](/docs/devtools/reference.md) for details. ## Running the backend on its own[​](#running-the-backend-on-its-own "Direct link to Running the backend on its own") The adapters start the dashboard server in-process, so you normally never touch it. It also ships as a standalone binary, which is what you want when the dashboard should outlive a single run - or when the tests are not JavaScript, as with the Python adapter (see the [Selenium](/docs/devtools/selenium.md) page). ``` npx @wdio/devtools-backend ``` ``` Usage: devtools-backend [options] Options: --port Preferred port; a free one is chosen if it is taken --hostname Host to bind (default: localhost) -h, --help Show this message ``` Both `--port 8080` and `--port=8080` forms are accepted. `--port` is a *preference*, not a promise: if that port is taken the server binds a free one instead of failing. It prints the port it actually bound, which is the line to read rather than the one you asked for: ``` devtools-backend listening at http://localhost:3000 ``` The Python adapter attaches to an already-listening server when `DEVTOOLS_PORT` is set, instead of starting a second one. The JavaScript adapters start their backend in-process; use their `port` option to choose the port. A second binary, `show-trace`, opens a trace archive in the offline player - see [Trace Player](/docs/devtools/trace-player.md). --- Source: https://webdriver.io/docs/devtools/wdio/interactive-test-rerunning.md # Interactive Test Rerunning & Visualization Watch your tests execute in real-time with live browser previews and automatic screenshots captured after each WebDriver command. The UI displays a complete visual timeline of your test execution, showing the exact browser state at each step. After your initial test run completes, click on any test case or suite in the DevTools UI to re-execute it instantly. This eliminates the need to restart your entire test runner or modify your code, dramatically speeding up debugging cycles. **Key Features:** * **Real-time visualization** - Automatic screenshot capture after every command (click, toBeExisting, etc.) * **Live browser preview** - See your application's current state during test execution * **Command timeline** - View detailed logs with timestamps for each action * **Interactive rerunning** - Click any test or suite to re-execute it instantly * **Same dashboard window** - Reruns spawn a fresh test process and stream into the existing dashboard window, without opening new tabs * **Scrollable history** - Review any point in test execution ## Demo[​](#demo "Direct link to Demo") ### ▶️ Test Runner[​](#️-test-runner "Direct link to ▶️ Test Runner") ![Test Runner Demo](/assets/images/test-runner-3385e5ab2444f810c124ab031713322f.gif) ### 🛠️ Test Rerunner[​](#️-test-rerunner "Direct link to 🛠️ Test Rerunner") ![Test Rerunner Demo](/assets/images/test-rerunner-8a42c103076b980f185601cbfbc34fed.gif) ### 🛑 Stop Test Runner[​](#-stop-test-runner "Direct link to 🛑 Stop Test Runner") ![Stop Test Runner Demo](/assets/images/stop-runner-a7a5f5b4a1d9a08d451f732c1f9ed08b.gif) ### ⚡ Actions, Snapshot & Command Logs[​](#-actions-snapshot--command-logs "Direct link to ⚡ Actions, Snapshot & Command Logs") ![Actions, Snapshot \& Command Logs Demo](/assets/images/actions-command-logs-45f3978e4ee1276949373ee564024b22.gif) --- Source: https://webdriver.io/docs/devtools/wdio/preserve-and-rerun.md # Preserve & Rerun (Compare) When a test fails, the usual debugging loop is: rerun it, then compare two walls of logs to work out what changed. Preserve & Rerun collapses that into a single click. It **snapshots the failing run and re-executes the test in one action**, then shows both runs side-by-side in a **Compare** view aligned command-by-command - so you can see exactly where the two diverged without re-reading anything. This is the fastest way to diagnose a flaky test: the command that behaved differently between the pass and the fail is highlighted for you, along with the assertion that broke. Available on every adapter - **WebdriverIO**, **[Selenium WebDriver](/docs/devtools/selenium.md)** (Node.js and Python), and **[Nightwatch.js](/docs/devtools/nightwatch.md)**. The rerun filter differs per framework (WebdriverIO `--spec` plus a grep, Selenium `--grep` / `--testNamePattern`, Nightwatch `DEVTOOLS_RERUN_LABEL`, pytest node ids); the dashboard is identical. ## Demo[​](#demo "Direct link to Demo") ![Preserve \& Rerun Demo](/assets/images/preserve-rerun-52348ac5e421da1ec2d83f71a9848396.gif) ## How it works[​](#how-it-works "Direct link to How it works") 1. Run your tests as normal. When a test finishes in a **failed** state, hover its row in the sidebar. 2. A bug-play icon (🐞▶) appears next to the regular ▶ rerun button. It only shows on failed test/suite rows, wherever a plain rerun is already supported (e.g. Cucumber scenarios at the scenario row, Mocha/Jasmine tests at the test or suite row). 3. Click it. DevTools captures a snapshot of the failing run, then re-launches just that test. 4. The **Compare** tab opens with the two runs aligned by command. The point of divergence and the assertion error (**Expected vs Received**) are called out. ## Key Features[​](#key-features "Direct link to Key Features") * **One-click snapshot + rerun** - Preserve the failing run and re-execute it in a single action, no code changes or full-suite restart. * **Command-by-command alignment** - Both runs are laid out side-by-side and aligned by command, so differences stand out instantly. * **Failure point highlighted** - Jumps you straight to the command where the two runs diverged. * **Assertion diff** - Shows the assertion that broke with Expected vs Received side-by-side. * **Pop-out window** - Open the comparison in a separate, themed window for a roomier view. * **Flaky-test triage** - See which command differed between a pass and a fail without re-reading logs. ## Limitations[​](#limitations "Direct link to Limitations") * **Cucumber**: per-step rerun is disabled because Cucumber's `--name` filter targets scenarios, not individual Gherkin steps. Scenario-level Preserve & Rerun still works. --- Source: https://webdriver.io/docs/devtools/wdio/console-logs.md # Console Logs Capture and inspect all browser console output during test execution. DevTools records console messages from your application (`console.log()`, `console.warn()`, `console.error()`, `console.info()`, `console.debug()`) as well as WebDriverIO framework logs based on the `logLevel` configured in your `wdio.conf.ts`. **Features:** * Real-time console message capture during test execution * Browser console logs (log, warn, error, info, debug) * WebDriverIO framework logs filtered by configured `logLevel` (trace, debug, info, warn, error, silent) * Timestamps showing exactly when each message was logged * Console logs displayed alongside test steps and browser screenshots for context **Configuration:** ``` // wdio.conf.ts export const config = { // Level of logging verbosity: trace | debug | info | warn | error | silent logLevel: 'info', // Controls which framework logs are captured // ... }; ``` This makes it easy to debug JavaScript errors, track application behavior, and see WebDriverIO's internal operations during test execution. ## Demo[​](#demo "Direct link to Demo") ### >\_ Console Logs[​](#_-console-logs "Direct link to >_ Console Logs") ![Console Logs](/assets/images/console-logs-df2c515b2ab04a8ee2270dff1fb812ad.gif) --- Source: https://webdriver.io/docs/devtools/wdio/network-logs.md # Network Logs Monitor and inspect all network activity during your tests. DevTools captures every HTTP request and response, giving you complete visibility into API calls, resource loading, and network timing - just like browser DevTools. **What Gets Captured:** * **Request details** - URL, method, headers, query parameters, request body * **Response data** - Status code, response headers, response body, timing * **Resource types** - XHR/Fetch requests, scripts, stylesheets, images, and more * **Performance metrics** - Request timing, duration, and network waterfall This is invaluable for debugging API issues, identifying slow requests, validating data payloads, and understanding your application's network behavior during tests. ## Without WebDriver BiDi[​](#without-webdriver-bidi "Direct link to Without WebDriver BiDi") Safari and every session Appium serves (Safari on iOS, Chrome on Android) expose no WebDriver BiDi, so there the Network tab is filled by the page itself, through the same injected collector that records the DOM. It uses two sources of the page's own: * **`fetch` / `XMLHttpRequest` patch**: each call the page makes carries its method, headers, status and body. * **Resource Timing buffer**: every load the browser made (the document, scripts, styles, images, fonts) with its timing phases and size, plus a status on Chromium. The buffer is read when the collector installs, so loads made before it existed are included. Resource Timing cannot see headers or bodies, and on Safari it reports no status. Each such row says so in its detail card, a row with no status is coloured as unknown rather than as failed or still in flight, and the method column shows a dash where the browser names none. In a trace, the row's `trace.network` entry carries `_source: "resource-timing"` and the captured `_resourceType`, so a reopened trace renders the same row. A request both sources saw is listed once. When BiDi is serving the session, meaning it has delivered a network event and not merely accepted a subscription, the Resource Timing rows are dropped so each request is listed once. On Nightwatch, the Chrome performance log upgrades those rows in place with the headers and status it has. A native app session has no document, so neither source applies. Its network can be read from the appium-interceptor plugin instead when the session sets `appium:intercept: true`; see [Native app network](/docs/devtools/mobile.md#native-app-network). ## Demo[​](#demo "Direct link to Demo") ### 🌐 Network Logs[​](#-network-logs "Direct link to 🌐 Network Logs") ![Network Logs](/assets/images/network-logs-4f7fa09765687b158e850d900745e824.gif) --- Source: https://webdriver.io/docs/devtools/wdio/metadata.md # Metadata Inspect the full context of every browser session your test opens. The Metadata tab surfaces the capabilities, environment, and timing behind each run, so you can confirm exactly what was under test without digging through logs. **What Gets Captured:** * **Session capabilities** - Browser name and version, platform, and the negotiated WebDriver capabilities * **Session details** - Session ID, base URL, and viewport size * **Execution timing** - Test duration, status, and start/end timestamps * **Per-session view** - Each browser session (including sessions created by `browser.reloadSession()`) is preserved independently and selectable from a dropdown This is invaluable for diagnosing environment-specific failures, verifying the right capabilities were applied, and understanding how multi-session tests behaved. ## Demo[​](#demo "Direct link to Demo") ### 📋 Metadata[​](#-metadata "Direct link to 📋 Metadata") ![Metadata Demo](/assets/images/metadata-40a8a871fe14ad868b6ceb8cea306681.gif) --- Source: https://webdriver.io/docs/devtools/wdio/testlens.md # TestLens TestLens provides intelligent code navigation between the DevTools UI and your test source files. Click on any test or command in the UI to open its source at the exact line in the dashboard's **Source** tab, and from there open the file in VS Code. **How It Works:** * **Visual test hierarchy** - See your test structure (suites, tests, scenarios) in a tree view * **Source mapping** - Each test links to its exact location in your source files * **One-click navigation** - Click any test or command to show its source line in the **Source** tab * **Editor link** - The Source tab's **Open in editor** link opens the file at that line in VS Code (`vscode://file/...`) This seamless connection between UI and code speeds up debugging by eliminating manual code searching when investigating test failures. ## Demo[​](#demo "Direct link to Demo") ### 🔍︎ TestLens[​](#︎-testlens "Direct link to 🔍︎ TestLens") ![TestLens Demo](/assets/images/testlens-49f4d5e79d55554ce0442fa0be8d5522.gif) --- Source: https://webdriver.io/docs/devtools/wdio/multi-framework-support.md # Multi-Framework Support DevTools automatically works with Mocha, Jasmine, and Cucumber without requiring any framework-specific configuration. Simply add the service to your WebDriverIO config and all features work seamlessly regardless of which test framework you're using. **Supported Frameworks:** * **Mocha** - Test and suite-level execution with grep filtering * **Jasmine** - Complete integration with grep-based filtering * **Cucumber** - Scenario and example-level execution with feature :line targeting The same debugging interface, test rerunning, and visualization features work consistently across all frameworks. ## Configuration[​](#configuration "Direct link to Configuration") ``` // wdio.conf.js export const config = { framework: 'mocha', // or 'jasmine' or 'cucumber' services: ['devtools'], // ... }; ``` --- Source: https://webdriver.io/docs/devtools/wdio/screencast.md # Session Screencast Records browser sessions as `.webm` videos. Videos are displayed in the DevTools UI alongside the snapshot and DOM mutation views. Available across all three adapters - **WebdriverIO**, **[Selenium WebDriver](/docs/devtools/selenium.md)**, and **[Nightwatch.js](/docs/devtools/nightwatch.md#screencast)**. The capture mode differs per framework (CDP push where possible, polling otherwise - see [Browser Support](#browser-support) below). ## Demo[​](#demo "Direct link to Demo") ![Screencast Demo](/assets/images/screencast-43f96abae5f3a3ab641e14f36f05d9a5.gif) ## Setup[​](#setup "Direct link to Setup") Screencast encoding requires the **ffmpeg** binary on `PATH`. The `fluent-ffmpeg` wrapper installs with the adapter, so there is nothing else to add: ``` # Install ffmpeg - https://ffmpeg.org/download.html brew install ffmpeg # macOS sudo apt install ffmpeg # Ubuntu/Debian ``` Without ffmpeg the recorder still runs, but the encode step logs a warning and writes no file. ## Configuration[​](#configuration "Direct link to Configuration") ``` services: [ [ 'devtools', { screencast: { enabled: true, captureFormat: 'jpeg', quality: 70, maxWidth: 1280, maxHeight: 720, } } ] ] ``` ## Options[​](#options "Direct link to Options") | Option | Type | Default | Description | | ----------------- | ----------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `enabled` | `boolean` | `false` | Enable session recording | | `captureFormat` | `'jpeg' \| 'png'` | `'jpeg'` | Frame image format. **Chrome/Chromium only** - controls the format Chrome sends over CDP. Ignored in polling mode (Firefox, Safari) where screenshots are always PNG. Does not affect the output video container, which is always `.webm` | | `quality` | `number` | `70` | JPEG compression quality 0-100. Only applies in Chrome/Chromium CDP mode with `captureFormat: 'jpeg'` | | `maxWidth` | `number` | `1280` | Maximum frame width in pixels. **Chrome/Chromium only** - Chrome scales frames before sending over CDP. Ignored in polling mode | | `maxHeight` | `number` | `720` | Maximum frame height in pixels. **Chrome/Chromium only** - same as above | | `pollIntervalMs` | `number` | `200` | Screenshot interval in milliseconds for non-Chrome browsers (polling mode). Lower = smoother video but more WebDriver round-trips during test execution | | `maxBufferFrames` | `number` | `2000` | Cap on frames held in memory. Past it the buffer is thinned in place, keeping the first and last frames | ## Browser Support[​](#browser-support "Direct link to Browser Support") Recording works across all major browsers using automatic mode selection: | Browser | Mode | Notes | | ------------------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Chrome / Chromium / Edge | **CDP push** | Chrome pushes frames over the DevTools Protocol. Efficient - no impact on test command timing | | Firefox / Safari / others | **BiDi polling** | Falls back to calling `browser.takeScreenshot()` at `pollIntervalMs` intervals. Works wherever WebDriver screenshots are supported; adds a small overhead proportional to the interval | No configuration change is needed to switch modes - the service detects browser capabilities automatically and logs which mode is active. ## Behaviour[​](#behaviour "Direct link to Behaviour") * Recording starts when the browser session opens and stops when it closes. * Leading blank frames (captured before the first URL navigation) are automatically trimmed so videos begin at the first meaningful page action. * If `browser.reloadSession()` is called mid-run, the service finalises the current recording and starts a fresh one for the new session. Each session produces its own `.webm` file. * When multiple recordings exist, the DevTools UI shows a **Recording N** dropdown to switch between them. ### Where output files land[​](#where-output-files-land "Direct link to Where output files land") Every adapter writes into a `test-results/` folder; the base directory it sits in differs, because the adapters share one resolver but feed it different inputs: | Adapter | Output location | | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **WebdriverIO** | `/test-results/` if `outputDir` is explicitly set in `wdio.conf.ts`, otherwise `/test-results/` (`rootDir` is the dir containing the config). Avoid setting `outputDir` just to control video paths - WDIO redirects worker logs there too. | | **Selenium** | `test-results/` in the directory of the test file that just ran, falling back to `process.cwd()`. | | **Nightwatch** | `test-results/` in the directory of the test file, falling back to the directory containing `nightwatch.conf.*`, then `process.cwd()`. | Directories under `node_modules/` are skipped on the Selenium/Nightwatch path so symlinked workspaces don't dump videos into a dependency folder, and a directory that isn't writable falls through to the next candidate. ## Output Files[​](#output-files "Direct link to Output Files") Live mode streams captured data to the dashboard over WebSocket and writes **no trace file to disk** — for a portable artifact, use [trace mode](/docs/devtools/wdio/trace-mode.md) (`trace.zip`). The only file live mode writes is the screencast video, and only when `screencast.enabled: true`. Filenames are adapter-specific (the framework name appears in the prefix): | Adapter | Screencast video | | ----------- | ----------------------------------- | | WebdriverIO | `wdio-video-{sessionId}.webm` | | Selenium | `selenium-video-{sessionId}.webm` | | Nightwatch | `nightwatch-video-{sessionId}.webm` | --- Source: https://webdriver.io/docs/devtools/wdio/trace-mode.md # Trace Mode Headless capture path — no DevTools UI window opens. At session end the adapter writes trace artifacts into a `test-results/` folder: under WebdriverIO's `outputDir` (or `rootDir`), and for Selenium and Nightwatch next to the test file, falling back to the config directory, then the current directory. For `session` / `spec` granularity that's a `trace-.zip` (or a `trace-/` directory); for `test` granularity each test gets its own subfolder (see [Trace granularity](#trace-granularity--tracegranularity)). The artifact is portable and ships everything needed for offline replay, AI-agent diffing, or any consumer that prefers a file over a live UI. Trace mode is **mutually exclusive with live mode**. Pick one per session: humans debugging interactively want live; agents diffing runs or CI bots collecting artifacts want trace. ## Enable[​](#enable "Direct link to Enable") ``` // wdio.conf.ts services: [ [ 'devtools', { mode: 'trace', traceFormat: 'zip' // optional; 'zip' (default) | 'ndjson-directory' } ] ] ``` Trace mode needs WebDriver BiDi (Chrome 114+, Firefox 130+), which WebdriverIO enables automatically. To try it, run the mocha example in trace mode with `DEVTOOLS_MODE=trace pnpm demo:wdio:mocha`; add `DEVTOOLS_TRACE_GRANULARITY=test DEVTOOLS_TRACE_POLICY=retain-on-failure` for per-test retention. The config is [`examples/wdio/mocha/wdio.conf.ts`](https://github.com/webdriverio/devtools/blob/main/examples/wdio/mocha/wdio.conf.ts). Selenium and Nightwatch ship the same trace pipeline — see their adapter pages for framework-specific enable syntax: [Selenium](/docs/devtools/selenium.md#trace-mode) · [Nightwatch](/docs/devtools/nightwatch.md#trace-mode). ## What's inside the artifact[​](#whats-inside-the-artifact "Direct link to What's inside the artifact") | File | Contents | | ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `trace.trace` | NDJSON `context-options` + `before` / `after` action events; one line per record | | `trace.network` | HAR-style network entries, one per line; an entry read from the page's Resource Timing buffer (no BiDi, e.g. Safari or Appium) carries `_source: "resource-timing"` and `_resourceType` | | `trace.mutations` | NDJSON DOM mutation stream behind DOM time-travel; omitted when nothing was captured | | `transcript.md` | Human/LLM-readable Markdown summary with timing, selectors, value annotations | | `resources/page@-.jpeg` | Screenshot taken at each user-facing action | | `resources/page@--elements.json` | Flat list of interactable elements at that action | | `resources/page@--snapshot.txt` | Depth-indented accessibility-tree snapshot (AI-friendly) | | `resources/.jpeg` | Dense filmstrip frames, content-addressed | | `resources/src@.txt` | Captured test source for the Source tab | | `resources/` | Network response bodies, content-addressed | ### What counts as an "action"[​](#what-counts-as-an-action "Direct link to What counts as an \"action\"") Commands are filtered through an allow-list before they produce trace entries. Examples that land in the trace: * `url` / `get` → `Page.navigate` * `click` → `Element.click` * `setValue` / `sendKeys` → `Element.fill` * `submit`, `clear`, `selectByVisibleText`, … Locator resolution (`$`, `$$`, `findElement(s)`), Selenium's `executeScript` polling and the `clearValue` that `setValue` fires internally are deliberately excluded: they don't represent user-facing intent and would noise up the timeline. Explicit waits (`waitFor*`, `waitUntil`, Nightwatch `waitForElement*`, Selenium `driver.wait`, Python `WebDriverWait`; see [Waits](#waits)), element reads (`getText`, `isDisplayed`, …), page reads such as `getTitle`, and `execute` do appear. The allow-list is `ACTION_MAP` in [`packages/shared/src/trace-actions.ts`](https://github.com/webdriverio/devtools/blob/main/packages/shared/src/trace-actions.ts). ### Waits[​](#waits "Direct link to Waits") A wait the test wrote is one row, named after what it waited for: `Element.waitForExist` on its selector for a wait on an element locator, `Element.waitForDisplayed` for a wait on an element's visibility, and `Browser.waitForFunction` for a wait on any other condition. The row appears as soon as the wait starts and is updated when it ends, so the live dashboard shows a long wait as running rather than listing it only once it is over. A wait that times out is a failed row carrying the timeout, in the Actions list, the Errors tab and the trace. The commands the wait's condition issued nest under its row, one row per distinct call rather than one per poll, in the live dashboard and the trace player alike. They are collapsed by default, and open by themselves when the wait failed or holds the selected row. The chevron beside a wait is a button of its own, so the keyboard reaches it (`Enter` or `Space` expands or collapses it) while `Enter` on the row still selects the wait. A wait started inside another wait's condition nests under that wait. A command under a wait that failed before the wait passed, such as a `getText` on an element that appears a moment later, is a poll the wait retried past, not a failure: it shows neutral with its error in a tooltip, does not open the wait, and is left out of the Errors tab, the copied failures and the trace's errors. Under a wait that timed out, the same commands keep their errors, since the last poll is what explains the timeout. What each adapter shows: | Adapter | Waits | Nested under the wait | | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | WebdriverIO | `waitUntil` and the `waitFor*` family | The commands a `waitUntil` condition issued, and the polls of an element wait (such as `isExisting`). | | Nightwatch | `waitUntil` and the `waitForElement*` family | The commands a `waitUntil` condition issued. A `waitForElement*` row has no children: Nightwatch polls for the element through its own transport, which the plugin does not see. | | Selenium (Node.js) | `driver.wait(...)`. `until.elementLocated` is `waitForElementLocated` (`Element.waitForExist`) on its locator, `until.elementIsVisible` is `waitForElementVisible` (`Element.waitForDisplayed`), and any other condition is `wait` (`Browser.waitForFunction`), labelled with the condition's description. | The commands the condition issued. An element wait's `findElement(s)` polls nest in the live dashboard but are left out of the trace, like every locator lookup. | | Selenium (Python) | `WebDriverWait(...).until(...)` and `until_not(...)`. `EC.presence_of_element_located` is `waitForElementLocated` (`Element.waitForExist`), `EC.visibility_of_element_located` is `waitForElementVisible` (`Element.waitForDisplayed`), and any other condition, every `until_not` included, is `wait` (`Browser.waitForFunction`), labelled with the condition (an `expected_conditions` condition by its name and arguments). | As for Node.js. | ## Output format — `traceFormat`[​](#output-format--traceformat "Direct link to output-format--traceformat") ``` { mode: 'trace', traceFormat: 'zip' | 'ndjson-directory' // default: 'zip' } ``` * **`zip`** (default) — single archive at `test-results/trace-.zip`. * **`ndjson-directory`** — same files unpacked into `test-results/trace-/`. One less unzip step for scripted or agentic consumers that want to grep / stream the NDJSON directly. The `zip` opens in the first-party [`show-trace` player](/docs/devtools/trace-player.md); an `ndjson-directory` trace opens in other compatible trace viewers, or zip it first to open it in `show-trace`. ## Trace granularity — `traceGranularity`[​](#trace-granularity--tracegranularity "Direct link to trace-granularity--tracegranularity") How many trace artifacts a run produces: ``` { mode: 'trace', traceGranularity: 'session' | 'spec' | 'test' // default: 'session' } ``` | Value | Output | | ------------------- | ------------------------------------------------------------------------------------------------------------- | | `session` (default) | One trace per worker/session — `test-results/trace-.zip`. | | `spec` | One trace per spec file, at `test-results/trace---.zip`. Smaller, easier to navigate. | | `test` | One trace **per test**, each in its own folder: `test-results/--<browser>[-retry<N>]/trace.zip`. | For `test` granularity the folder name is built from the spec basename, a slug of the test title, the browser, and a `-retry<N>` suffix on retried attempts — e.g. `test-results/login_e2e-logs-in-chrome/trace.zip`, with a first retry at `test-results/login_e2e-logs-in-chrome-retry1/trace.zip`. Per-test traces are the most navigable and pair best with a retention policy so only the traces you care about are written. ## Retention — `tracePolicy`[​](#retention--tracepolicy "Direct link to retention--tracepolicy") By default every trace is kept (`'on'`). To keep only the interesting ones — ideal with `traceGranularity: 'test'`: ``` { mode: 'trace', traceGranularity: 'test', tracePolicy: 'retain-on-failure' // default: 'on' } ``` | Policy | Keeps the trace when… | | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `'on'` (default) | Always — every trace is written. | | `'retain-on-failure'` | The test's **final** attempt failed. A fail-then-pass retry sequence ends `passed`, so it is *not* kept — you don't over-retain a flake that eventually went green. | | `'retain-on-first-failure'` | **Attempt 0** failed, regardless of whether a later retry passed. | | `'on-first-retry'` | The test was retried at least once (an attempt 1 exists). | | `'on-all-retries'` | Any retried attempt (attempt ≥ 1) exists. | | `'retain-on-failure-and-retries'` | The final attempt failed **or** the test was retried. | A non-retained slice is decided against and never written to disk. The retry-aware policies key on a per-attempt **outcome ledger** the adapter keeps per retry-stable test id, so `retain-on-failure` and `retain-on-first-failure` evaluate the right attempt. Where a runner doesn't expose per-attempt retry information, every policy except `retain-on-failure` degrades to `retain-on-failure`; a run with no observed outcomes (e.g. a plain standalone script) fails **open** and keeps the trace rather than risk dropping one you need. > Retry-aware retention is verified end-to-end for **WebdriverIO** (mocha / cucumber) and **Selenium** (mocha). For **Nightwatch**, `retain-on-failure` works, but the other retry-aware policies degrade to it because Nightwatch's `--retries` re-runs a testcase internally without re-firing the per-test hooks. WDIO's cross-process `specFileRetries` also falls outside the (per-worker) ledger. See the [Nightwatch adapter page](/docs/devtools/nightwatch.md#trace-mode) for the specifics. ## Dense filmstrip — `filmstrip`[​](#dense-filmstrip--filmstrip "Direct link to dense-filmstrip--filmstrip") **By default** the trace records a **dense, continuous** screencast so the player scrubs smooth playback rather than jumping frame-to-frame. The dense frames sit alongside the per-action frames (which carry the DOM snapshots). Set `filmstrip: false` to record only one frame per action — a smaller trace with no continuous recorder: ``` { mode: 'trace', filmstrip: false // opt out — one frame per action (default is true) } ``` * Dense frames are added **alongside** the per-action frames (which carry the DOM snapshots), so no DOM data is lost — when dense frames are present they supersede the sparse per-action filmstrip for scrubbing. * Frames are thinned at export (≥100 ms apart) and content-addressed, so identical frames (a static wait) collapse to one resource. The live session buffer is bounded by `screencast.maxBufferFrames` (default 2000). * Recording uses the screencast recorder — CDP push on Chrome/Chromium, screenshot polling elsewhere. On non-Chrome browsers the polling issues many `takeScreenshot` commands; pair with your reporter's step-silencing option (see [Allure Integration](/docs/devtools/allure.md)). `filmstrip` is available on all three adapters (WebdriverIO / Selenium / Nightwatch). ## Per-test screenshot & video — `screenshot` / `video`[​](#per-test-screenshot--video--screenshot--video "Direct link to per-test-screenshot--video--screenshot--video") At `traceGranularity: 'test'` each test can also produce a standalone screenshot and/or a per-test video slice, mirroring the familiar screenshot/video-on-failure ergonomics: ``` { mode: 'trace', traceGranularity: 'test', screenshot: 'only-on-failure', // 'off' (default) | 'on' | 'only-on-failure' video: 'retain-on-failure' // 'off' (default) | any tracePolicy value } ``` | Option | Values | Behavior | | ------------ | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `screenshot` | `'off'` (default) · `'on'` · `'only-on-failure'` | `'on'` captures after every test; `'only-on-failure'` only after a failing test. PNG. | | `video` | `'off'` (default) · any `tracePolicy` value | Records the screencast continuously and keeps each test's slice per the same retention semantics as `tracePolicy`. WebM; encoding needs `ffmpeg` on `PATH`. Setting a non-`off` value starts the recorder on its own — you don't also need `filmstrip` or `screencast.enabled`. | Both are gated to trace mode + `traceGranularity: 'test'` (the per-test scope these attach to). At coarser granularities they no-op. * **WebdriverIO** — `screenshot` / `video` are service options; attached inline to Allure when `@wdio/allure-reporter` is present. * **Selenium** — same options on its `DevToolsOptions`; attached inline to Allure via `allure-js-commons` when an Allure runner adapter is active. * **Nightwatch** — **produce-only**: the files are written to the trace output dir (and listed in the manifest), but not attached inline to Allure — Nightwatch has no live Allure attach API. See [Trace Mode Limitations](/docs/devtools/limitations.md). > `screencast.enabled` is the separate **live-mode** continuous `.webm` recording and is ignored in trace mode. In trace mode use `filmstrip` (dense frames into the trace) or per-test `video`; the screencast tuning fields (`quality`, `maxWidth`, `pollIntervalMs`, …) still apply to whichever recorder runs. ## Artifacts manifest — `emitArtifactsManifest`[​](#artifacts-manifest--emitartifactsmanifest "Direct link to artifacts-manifest--emitartifactsmanifest") Writes a `devtools-artifacts-<sessionId>.json` next to the trace — a generic index that reporters and CI consume to discover the produced artifacts (every trace / screenshot / video, plus each test's state): ``` { mode: 'trace', emitArtifactsManifest: true // default: off; auto-on when Allure is detected } ``` * **Off by default.** It **auto-enables** when an Allure reporter is detected — WebdriverIO's `@wdio/allure-reporter` in the config, or an active Selenium `allure-js-commons` runtime. * **Nightwatch is opt-in**: it has no live Allure signal to auto-detect against (`nightwatch-allure` is post-hoc), so it never auto-enables — set it explicitly if you want the manifest. ## Assertions — `captureAssertions`[​](#assertions--captureassertions "Direct link to assertions--captureassertions") Assertions surface as first-class action rows in the trace (on by default; set `captureAssertions: false` to opt out): * **`node:assert`** — captured across all three JavaScript adapters as `assert.<method>` rows. The Python adapter captures Python's own `assert` statement the same way; see the Python tab of [Selenium → Assertions](/docs/devtools/selenium.md#assertions). * **WebdriverIO `expect`** — passing *and* failing `expect(...)` matchers (`expect($el).toHaveText(...)`, `toBeExisting()`, …) appear as `expect.<matcher>` rows carrying the expected value, the element's source location, and a snapshot; the matcher's internal polling commands are suppressed so only the assertion shows. * **Nightwatch `browser.assert.*` / `browser.verify.*`** — native assertions surface as `assert.<m>` / `verify.<m>` rows. Passing assertions render green; failing ones render red with the error message. An assertion row names the element it is about, so selecting it boxes that element in the snapshot. A `node:assert` call (or a Python `assert`) takes values rather than elements, so its element comes from where the asserted value was read: `assert.equal(await heading.getText(), 'Secure Area')` names `heading`'s selector, and so does a value from any other element read, `getHTML` and `getComputedRole` included. Only a read made earlier in the same test (or Cucumber scenario) counts, and a value read from the page itself rather than from an element, such as the title or the URL, names no element, even when some element's text reads the same: `assert.notEqual(await browser.getTitle(), 'Secure Area')` boxes nothing. WebdriverIO's `browser.getTitle()` is a `Page.getTitle` row of its own, and `expect(browser).toHaveTitle(...)` folds into that read as one `expect.toHaveTitle` row. ## Mobile testing[​](#mobile-testing "Direct link to Mobile testing") Appium sessions are captured in live and trace mode. The discriminator is the **browser name** in the capabilities, not the device: * **Mobile web** (Chrome on Android, Safari on iOS): same DOM-based snapshot pipeline as desktop. * **Native app** (no `browserName`): the page-injected DOM scripts are guarded off; the Appium XML tree feeds the snapshot serializer instead. * **Hybrid app**: only WebdriverIO follows the session into its webview; the other adapters decide from the startup capabilities. The trace's `context-options` records the platform, model and OS version so the viewer labels frames correctly. Run the examples with `pnpm demo:wdio:mobile` (also `:selenium:mobile`, `:nightwatch:mobile`, `:python:mobile`). See **[Mobile Testing](/docs/devtools/mobile.md)** for the full reference. ## Viewing the artifact[​](#viewing-the-artifact "Direct link to Viewing the artifact") Open a trace in the first-party **[Trace Player](/docs/devtools/trace-player.md)** — the WebdriverIO DevTools UI in a dedicated read-only player mode: ``` show-trace trace-<sessionId>.zip # bin on PATH after install npx show-trace trace-<sessionId>.zip # or via npx ``` The player gives you DOM time-travel, the A11y tab and pick-locator overlay, the Transcript tab with Copy-for-LLM, the Errors / Console / Network / Source dock tabs, and a scrubbable timeline. The same portable `.zip` also opens in other standalone trace viewers and inside an Allure report's embedded viewer. See the **[Trace Player](/docs/devtools/trace-player.md)** page for the full walkthrough, features, and keyboard shortcuts. ## Locators in the A11y tab[​](#locators-in-the-a11y-tab "Direct link to Locators in the A11y tab") The `show-trace` bin shipped by each adapter opens the same archive in the DevTools player, which additionally exposes an **A11y tab**: the accessibility tree captured per action, where clicking a row copies that element's locator. Those locators are written in the recording runner's own dialect, so they paste straight into the framework that produced the trace. An element identified only by its text is `a*=Logout` under WebdriverIO and `//a[contains(., "Logout")]` under Selenium — captioned with the call that resolves it, `By.xpath()`. Nightwatch prefers a native CSS locator such as `button[type="submit"]`, because it is the only runner that reads a bare selector string under a default CSS strategy, and falls back to XPath (captioned `useXpath()` / `locateStrategy: 'xpath'`) only when no unique CSS locator exists. Every other locator is portable CSS. For LLM / agent consumption, read `transcript.md` directly — it's a tight Markdown rendering of the actions with selectors and values. ## Learn more[​](#learn-more "Direct link to Learn more") * **[Trace Player](/docs/devtools/trace-player.md)** — the full `show-trace` player walkthrough, features, and keyboard shortcuts. * **[Allure Integration](/docs/devtools/allure.md)** — how trace / screenshot / video artifacts attach to an Allure report. * **[Cross-Framework Support](/docs/devtools/cross-framework.md)** — the per-adapter capability matrix (WebdriverIO / Selenium / Nightwatch). * **[Trace Mode Limitations](/docs/devtools/limitations.md)** — what trace mode skips and the known per-adapter gaps. * **[Configuration Reference](/docs/devtools/reference.md)** — every option at a glance. --- Source: https://webdriver.io/docs/devtools/trace-player.md # Trace Player The `show-trace` player opens any trace produced in [Trace Mode](/docs/devtools/wdio/trace-mode.md) in the WebdriverIO DevTools UI itself — a dedicated, read-only **player** mode for offline replay, review, and AI-agent diffing. ## Demo[​](#demo "Direct link to Demo") ![Trace Player Demo](/assets/images/trace-player-16329949c7ed70183e2b9f38d41882b7.gif) ## `show-trace` — the first-party player[​](#show-trace--the-first-party-player "Direct link to show-trace--the-first-party-player") Open a trace in the DevTools UI: ``` show-trace trace-<sessionId>.zip # bin on PATH after install npx show-trace trace-<sessionId>.zip # or via npx pnpm show-trace trace-<sessionId>.zip # from the devtools monorepo ``` The `show-trace` bin ships with each adapter (`@wdio/devtools-service`, `@wdio/nightwatch-devtools`, `@wdio/selenium-devtools`), so it's available in any project that installs one, with no extra dependency. It is also a bin of `@wdio/devtools-backend` itself, so a project without a JavaScript adapter (for example a Python one) can run `npx -p @wdio/devtools-backend show-trace <trace.zip>`. It boots the same DevTools UI in a dedicated **player** mode and opens it in your browser: * **Action list** (left) — the captured commands, with a **Metadata** tab alongside. A wait is one row with the commands its condition issued nested under it, collapsed unless the wait failed or holds the selected row; see [Waits](/docs/devtools/wdio/trace-mode.md#waits). * **Browser pane** (centre) — the reconstructed page for the selected action (see [DOM time-travel](#trace-player-features) below). When the trace carries a filmstrip/video, a **Snapshot / Screencast** toggle switches to the recorded video. * **Timeline strip** (top) — a filmstrip of thumbnails at their wall-clock positions plus a scrub bar with a draggable playhead. Click a thumbnail or drag anywhere to seek. * **Controls bar** — play/pause, step, and speed. * **Dock tabs** (bottom) — **Source**, **Log**, **Console**, **Network**, **Errors** (each badged with its count), plus the player-only **A11y** and **Transcript** tabs. Click a **Network** row for the request detail (headers, timing, status). * **Keyboard shortcuts** — `Space` play/pause, `←`/`→` step between actions, `Home`/`End` jump to first/last, `,`/`.` change speed, `/` focus filter, `?` show all shortcuts. > Accepts a `.zip` only; zip an `ndjson-directory` trace first, or open it in another compatible viewer. The same shortcuts work in the live dashboard (`←`/`→` walk the command list, `?` shows help). ### Trace player features[​](#trace-player-features "Direct link to Trace player features") Beyond static frame stepping, the player reconstructs and cross-references the run: * **DOM time-travel** — the browser pane replays the captured DOM-mutation stream (and form field-state — input `value`, checkbox `checked`, including fields cleared back to empty) to rebuild the *real* DOM as of the selected action's time, not just a screenshot. Points that carry no captured frame (assertions, static waits) still show the true page state. * **A11y tab + element overlay ("pick locator")** — the **A11y** tab shows the accessibility tree (roles + accessible names) captured for the selected command. Toggle the element overlay in the browser chrome to outline every element the test interacted with; **hover** a box to highlight its row in the A11y tree, **click** to copy a resilient locator. Locators are written in the recording runner's dialect: `a*=Logout` under WebdriverIO, `//a[contains(., "Logout")]` with a `By.xpath()` caption under Selenium, and plain CSS under Nightwatch with an XPath fallback. On a native Appium session they read as `android=new UiSelector()…` or `-ios predicate string:…`. The link is bidirectional — hovering a tree row highlights the element back in the snapshot. * **Transcript tab + Copy-for-LLM** — the **Transcript** tab renders the run's `transcript.md` (a human/LLM-readable summary in execution order). A one-click **Copy** bundles the transcript with any failing-command errors as paste-ready context for an LLM. * **Timeline input markers** — each action is marked on the scrub bar by kind: keyboard actions as a green bar, pointer actions (which carry a hit point) as a blue dot, others as a plain tick — so you can read the interaction rhythm at a glance. * **Cucumber nesting** — Cucumber runs nest under their scenario in the action tree. Depth varies by adapter (Selenium nests Feature → Scenario → Step, WebdriverIO Scenario → Step, Nightwatch Feature → Scenario); see [Cross-Framework Support](/docs/devtools/cross-framework.md). * **Dense filmstrip scrubbing** — with [`filmstrip`](/docs/devtools/wdio/trace-mode.md#dense-filmstrip--filmstrip) enabled, the timeline packs the dense frames for smooth scrubbing instead of one-frame-per-action jumps. ## Other trace viewers[​](#other-trace-viewers "Direct link to Other trace viewers") Because the artifact uses a portable, standard trace-viewer on-disk format, the same `.zip` (or directory) also opens in compatible **standalone trace viewers**, and — sharing that format — inside an **Allure report's embedded trace viewer** (Allure ≥ 2.35). They render: * Timeline of actions with timings * Per-action screenshots * Element snapshots * Network waterfall * Console events For LLM / agent consumption, read `transcript.md` directly — it's a tight Markdown rendering of the actions with selectors and values. The trace pipeline (action-mapping, snapshot serializers, NDJSON writer, zip / directory writer) is shared across adapters via [`@wdio/devtools-trace`](https://github.com/webdriverio/devtools/tree/main/packages/trace), so the artifact shape is identical no matter which adapter produced it — see [Cross-Framework Support](/docs/devtools/cross-framework.md). --- Source: https://webdriver.io/docs/devtools/allure.md # Allure Integration Trace-mode artifacts — the trace zip and each test's per-test screenshot and video — attach to an Allure report automatically, so you can open them straight from the report. See [Trace Mode](/docs/devtools/wdio/trace-mode.md) for how to enable trace mode and produce these artifacts. When an Allure reporter is present, trace-mode artifacts attach to the Allure report automatically — no extra wiring: * **`traceGranularity: 'test'`** — each test's `trace.zip` (`application/zip`, a download that opens in `show-trace`), `screenshot` (`image/png`, inline) and `video` (`video/webm`, inline) attach to that test's card. This is the granularity to use for a per-test Allure report. Encoding the per-test `video` needs `ffmpeg` on `PATH`. * **`traceGranularity: 'session'` / `'spec'`** — a session/spec-spanning trace is written to disk and enumerated in the [artifacts manifest](/docs/devtools/wdio/trace-mode.md#artifacts-manifest--emitartifactsmanifest), but **not** attached to individual test cards: a session/spec trace is only finalized after all its tests have run, by which point their Allure cards are closed and there is no open test to attach to. To surface it anyway, post-process the manifest in your own `onComplete` hook. Per-adapter support: | Adapter | Attach mechanism | | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | | **WebdriverIO** | First-class via `@wdio/allure-reporter`'s `addAttachment`. | | **Selenium** | Via `allure-js-commons`' `attachment()` — runtime-agnostic, attaches under any Allure runner adapter, gated on an active `allure-js-commons` runtime. | | **Nightwatch** | **Produce-only** — files + manifest are written but not attached inline (no live Allure attach API). | **Embedded trace viewer.** Because the archive uses a portable, standard trace-viewer on-disk format, an Allure report's own **embedded trace viewer** (Allure ≥ 2.35) can open the attached `trace.zip` directly inside the report. **Report noise.** In trace mode the capture takes a per-action `takeScreenshot` to build the timeline; Allure logs every WebDriver command as a step and a screenshot per `takeScreenshot`. Silence that flood with the reporter's own options — the trace / screenshot / video attachments are unaffected: ``` reporters: [ ['allure', { outputDir: 'allure-results', disableWebdriverStepsReporting: true, disableWebdriverScreenshotsReporting: true }] ] ``` --- Source: https://webdriver.io/docs/devtools/mobile.md # Mobile Testing DevTools captures Appium sessions in both live mode and [Trace Mode](/docs/devtools/wdio/trace-mode.md). What it captures depends on one question — **does this session have a web document right now?** — because every DOM drain, page script and viewport read is a round trip that can only fail without one. ## Three kinds of session[​](#three-kinds-of-session "Direct link to Three kinds of session") | Session | Has a document | What is captured | | ----------------------------------------------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **Mobile browser** (Chrome on Android, Safari on iOS) | always | DOM time-travel, console and replay as on desktop; network from the page's own record, since Appium serves no BiDi (see [Network Logs](/docs/devtools/wdio/network-logs.md#without-webdriver-bidi)) | | **Native app** | never | commands, screenshots and element data from the platform's XML tree; no DOM | | **Hybrid app** | only while in a webview context | native halves as an app, webview halves as a page | The discriminator is the **browser name in the capabilities**, not the device: a mobile browser states one, a native app states none. A device is not required either — a Mac2, WinAppDriver or tvOS session has no document and is treated the same way. ## Hybrid apps and the active context[​](#hybrid-apps-and-the-active-context "Direct link to Hybrid apps and the active context") A hybrid app is the case capabilities alone cannot answer, because the answer changes during the run. Appium reports either `NATIVE_APP` or a webview context, and **anything that is not `NATIVE_APP` counts as a webview** — the `WEBVIEW_` prefix is a convention, and a driver naming its webview differently would otherwise have its DOM capture skipped. Following the context costs no extra round trip: the context-switch command carries its destination in its own arguments, and a switch that failed is ignored. ## Adapter support[​](#adapter-support "Direct link to Adapter support") All four adapters detect a native session and skip page-side capture on one. They differ only on hybrid apps: | Feature | WebdriverIO | Selenium | Nightwatch | Python | | ------------------------------------------------------------------ | --------------------- | ---------- | ---------- | ---------- | | Network without BiDi (Safari, Appium mobile browsers) | ⚠️ ¹ | ⚠️ ¹ | ⚠️ ¹ | ⚠️ ¹ | | Mobile browser sessions (Chrome on Android, Safari on iOS) | ✅ | ✅ | ✅ | ✅ | | iOS (XCUITest): native apps and Safari | ✅ | ✅ | ✅ | ✅ | | Native session detected, page-side capture skipped | ✅ | ✅ | ✅ | ✅ | | Follows a hybrid app into its webview | ⚠️ string form only ² | ⚠️ ³ | ⚠️ ³ | ⚠️ ³ | | Native app network through appium-interceptor (`appium:intercept`) | ✅ Android | ✅ Android | ✅ Android | ✅ Android | ✅ supported. ⚠️ partial, with the limit in the note below. ❌ not supported. Each supported cell is backed by the cross-adapter conformance suite, a named test or a manual check, listed in [the feature list](https://github.com/webdriverio/devtools/blob/main/packages/conformance/src/features.ts). ¹ Fetch and XHR calls carry headers and bodies; every other load comes from the page's Resource Timing buffer, with timing and size but no headers or body, and no status on Safari. ² Follows `switchContext('WEBVIEW_...')`; the object form (`{ title }` / `{ url }`) and `switchAppiumContext` leave capture on the native side. ³ Decides from the startup capabilities, so a hybrid app's webview half is captured as if it were still native. The **device itself** needs no adapter support: it is derived from the session's capabilities by the shared trace exporter on the way into the archive, and by the dashboard for a live session whose adapter sent none. Every adapter therefore gets the device frame. ## In the dashboard[​](#in-the-dashboard "Direct link to In the dashboard") A phone capture is framed as the device: a full-height device column with the action list and dock beside it, in **both** live mode and the [trace player](/docs/devtools/trace-player.md). The trace's `context-options` records the platform, model and OS version, read back on open so the player labels frames without guessing. On a native session the A11y tab and element data come from the platform's XML tree rather than the DOM, so locators read as `android=new UiSelector()…` or `-ios predicate string:…` rather than CSS or XPath over HTML. ## Native app network[​](#native-app-network "Direct link to Native app network") A native app has no document and Appium serves no BiDi network events, so by default the Network tab of a native session is empty. Every adapter can read the app's traffic from the [appium-interceptor](https://github.com/AppiumTestDistribution/appium-interceptor-plugin) plugin instead, which routes the device through a proxy of its own. Install the plugin and start Appium with it: ``` appium plugin install --source=npm appium-interceptor appium --use-plugins=appium-interceptor ``` Then ask for the proxy with `appium:intercept: true` in the session's capabilities (it is also read from inside `appium:options`): * WebdriverIO * Selenium (Node.js) * Nightwatch * Python ``` capabilities: [{ platformName: 'Android', 'appium:automationName': 'UiAutomator2', 'appium:app': '/path/to/app.apk', 'appium:intercept': true }] ``` ``` const driver = await new Builder() .usingServer('http://127.0.0.1:4723') .withCapabilities({ platformName: 'Android', 'appium:automationName': 'UiAutomator2', 'appium:app': '/path/to/app.apk', 'appium:intercept': true }) .build() ``` ``` desiredCapabilities: { browserName: null, platformName: 'Android', 'appium:automationName': 'UiAutomator2', 'appium:app': '/path/to/app.apk', 'appium:intercept': true } ``` ``` from appium.options.android import UiAutomator2Options options = UiAutomator2Options() options.app = "/path/to/app.apk" options.set_capability("appium:intercept", True) ``` The adapter starts a listener for each session, including one that replaces it mid-run, in both live and trace mode. It reads what the proxy recorded at most every 2 seconds between commands, because each read returns the whole history, and always at the end of each test (before that test's trace slice is written) and at the end of the session. Each request shows its method, URL, status, headers and bodies. The plugin records no timing, so a request is placed at the moment it was first read and shows no duration, and requests the app makes before the listener starts (its launch traffic) are not listed. Without the plugin the adapter logs a warning and the session runs as usual. This applies to native sessions only; a mobile browser session already captures its network through the page. The plugin supports Android. For HTTPS traffic the app has to trust the certificate the plugin installs on the device, which a release build usually does not (see Android's network security configuration). ## What a mobile trace does not contain[​](#what-a-mobile-trace-does-not-contain "Direct link to What a mobile trace does not contain") Per-action snapshots are issued from inside the command hook, and Appium serialises a probe behind the command it is observing. Where a session has a document to probe, that snapshot is therefore skipped. In practice: **a hybrid app's webview actions carry no per-action element data, accessibility tree or settle screenshot.** Native sessions, mobile browsers and every desktop session are unaffected. Command rows and their screenshots, console and the archive itself are always captured. A mobile browser's network comes from the page's Resource Timing buffer and its `fetch` / `XMLHttpRequest` patch rather than from BiDi, and a native session has no network capture unless it opts into the appium-interceptor plugin (see [Native app network](#native-app-network)), because the driver exposes none. These absences are by design. They are not a capture failure, and they are the main thing to know before debugging a hybrid trace. ## Running an example[​](#running-an-example "Direct link to Running an example") The repo carries one mobile example per adapter, and all four drive the same flow, so a difference between two dashboards is a difference in the adapter rather than in the test. The examples live in the [devtools repo](https://github.com/webdriverio/devtools), not in the adapter packages, so installing an adapter into your own project does not give you these scripts. Clone and build that repo once: ``` git clone https://github.com/webdriverio/devtools.git cd devtools pnpm install pnpm build ``` The Python example runs the `python3` on your `PATH`, so install the adapter and the Appium client into it first (a virtual environment keeps them out of your system Python): ``` python3 -m venv .venv source .venv/bin/activate pip install -e packages/selenium-devtools-py pip install -r examples/selenium-py/requirements-mobile.txt ``` Then, with Appium and a device ready (see [Prerequisites](#prerequisites)), run any of them from the root of that checkout: ``` pnpm demo:wdio:mobile pnpm demo:selenium:mobile pnpm demo:nightwatch:mobile pnpm demo:python:mobile ``` They drive the **Clock app**, which ships with every Android system image — so there is no `.apk` to supply, nothing to upload and no credentials. The flow stays on the timer setup screen: open the Timers tab, backspace the entry to zero, key a duration on the keypad, read it back, and correct it with backspace. They deliberately never **start** a timer. A running timer survives the session and replaces the setup screen with its card, so a spec that starts one is re-runnable only if it also finishes — an interrupted run would break every run after it. Not starting one removes that class of failure, and the keypad still exercises what an example is for: real input, real state change, captured. They also avoid Clock's preset chips, which look like fixed controls and are not: they are recently-used-duration suggestions, so a freshly reset Clock offers only the keypad and a preset-based flow fails on any device without timer history — including CI. Two Clock layouts exist on one app version, and the keypad is common to both. `DEVTOOLS_MODE=trace` switches any of them to trace mode, `DEVTOOLS_MOBILE=web` drives the device's own browser instead of an app — Chrome on Android, Safari on iOS — and `APPIUM_APP` points one at a real app. [`examples/MOBILE.md`](https://github.com/webdriverio/devtools/blob/main/examples/MOBILE.md) in the repo is the full setup guide. ## iOS[​](#ios "Direct link to iOS") ``` DEVTOOLS_MOBILE_PLATFORM=ios pnpm demo:wdio:mobile ``` **All four adapters.** Each carries an `android/` and an `ios/` spec directory and the runner picks between them, so the command above works with `demo:selenium:mobile`, `demo:nightwatch:mobile` and `demo:python:mobile` too. Capture itself was never platform-specific — what each adapter needed was a spec, not adapter work. iOS drives **Settings**, not Clock, because Clock is not installed on the simulator at all: `xcrun simctl listapps` lists Settings, Calendar, Reminders, Maps and Safari, and no Clock. Settings is on every simulator and every device, which is the same property that makes Clock the Android choice. The flow navigates into General and back, checking the navigation bar title each way — the same shape as the Android flow, with the app the platform actually ships. Android and iOS are **separate specs**, not one spec with a branch, because they share no selectors: iOS locators are accessibility ids and labels rather than resource-ids. `DEVTOOLS_MOBILE=web` works here too, and needs less than it does on Android: it opens **Safari**, which the XCUITest driver drives itself — no Chromedriver to match and nothing to add to the `appium` command. **Which simulator gets driven is resolved to a udid, never a bare name.** Naming one that does not exist does not fail — the XCUITest driver *creates* it and boots it, every run, beside the simulator already running, leaving a new simulator behind each time. So the examples default to whichever simulator is already booted, and an `IOS_DEVICE_NAME` matching none of them is refused with the list of booted ones rather than passed through. That is **local** policy. `xcrun simctl` enumerates local simulators and nothing else, so `IOS_UDID` names a device outright and is checked against nothing — a real device has no entry to match — and against a remote or cloud Appium (`APPIUM_HOST` set to anything but localhost) a device name is passed straight through, since naming one is how such a service selects it. Beyond the Android prerequisites, none of which iOS uses, you need Xcode (the Command Line Tools ship no simulators), a simulator runtime (`xcodebuild -downloadPlatform iOS`, a separate \~8 GB download), a booted simulator, and `appium driver install xcuitest` — whose first run also builds WebDriverAgent. Appium loads drivers at **startup**, so a server that was already running when you installed the driver will report that it cannot find XCUITest until you restart it. ## Prerequisites[​](#prerequisites "Direct link to Prerequisites") Running against a local Android emulator needs, beyond [Getting Started](/docs/devtools/getting-started.md): 1. **Java JDK** and the **Android SDK** — with `ANDROID_HOME` pointing at the SDK the `sdkmanager` on your `PATH` actually installs into, which is not always `~/Library/Android/sdk`. 2. **An AVD and a running emulator**, or a physical device with USB debugging. 3. **Appium with the UiAutomator2 driver** (`appium driver install uiautomator2`), or the XCUITest driver for iOS — see [iOS](#ios) above. 4. **A matching Chromedriver**, for a mobile browser or a hybrid app. A webview is driven by Chromedriver, and Appium's autodownload frequently has no build matching the Chrome on the system image — in either direction. It surfaces as `No Chromedriver found that can automate Chrome '<version>'` when entering a webview, which reads as a capture failure but is an environment gap. Start Appium with `--default-capabilities '{"appium:chromedriverExecutableDir": "<path>"}'` plus `--allow-insecure=uiautomator2:chromedriver_autodownload`. **A native-app run needs none of this.** 5. **Classic WebDriver protocol** for WebdriverIO — Appium's BiDi shim for UiAutomator2 does not implement every BiDi command, so set `'wdio:enforceWebDriverClassic': true` in the capability block. --- Source: https://webdriver.io/docs/devtools/cross-framework.md # Cross-Framework Support The trace format and the `show-trace` player are identical across WebdriverIO / Selenium / Nightwatch; this page shows where capture completeness differs. For the full trace-mode reference, see [Trace Mode](/docs/devtools/wdio/trace-mode.md). The transforms that build a trace live in [`@wdio/devtools-trace`](https://github.com/webdriverio/devtools/tree/main/packages/trace), one layer below the adapters, so the **trace format and the `show-trace` player are identical for every adapter**: the same `.zip` (or directory) opens in the same player regardless of which produced it. The JavaScript adapters additionally share the core options (`mode`, `traceGranularity`, `tracePolicy`, `traceFormat`, `filmstrip`, `emitArtifactsManifest`, `captureAssertions`). **Capture completeness varies by adapter**, though. WebdriverIO is the most complete; Selenium, Nightwatch and Python cover the core flow with the gaps noted below. Framework-specific enable syntax lives on each adapter page; see [Selenium](/docs/devtools/selenium.md#trace-mode) and [Nightwatch](/docs/devtools/nightwatch.md#trace-mode). The Python adapter (see the **Python** tabs on the [Selenium](/docs/devtools/selenium.md) page) writes the same archive and opens in the same player, and has its own column in the table below. It runs no JavaScript in the test process, so the backend builds its trace from the captured stream instead of the adapter building it in-process. Granularity and retention are set with `--devtools-trace-granularity session|test` and `--devtools-trace-policy`, the latter with its retry-aware values degrading to `retain-on-failure` because nothing on that wire carries an attempt number. | Feature | WebdriverIO | Selenium | Nightwatch | Python | | -------------------------------------------------------------------- | --------------------------------------- | ----------------------------------------- | ----------------------------- | ------------------------------------------------------- | | Trace mode + `show-trace` player | ✅ | ✅ | ✅ | ✅ | | DOM time-travel (mutation capture) | ✅ | ⚠️ with BiDi ¹ | ⚠️ with BiDi ¹ | ✅ | | Network requests (browser sessions) | ✅ | ⚠️ with BiDi ² | ⚠️ with BiDi ³ | ✅ | | Screencast (`filmstrip` / video) | ✅ CDP push (Chrome), polling elsewhere | ✅ CDP push (Chromium), polling elsewhere | ⚠️ polling only ⁴ | ✅ CDP push (Chromium), one frame per command elsewhere | | Per-test granularity (`traceGranularity: 'test'`) | ✅ | ✅ | ⚠️ ⁵ | ✅ | | Retry-aware retention (`tracePolicy`) | ✅ | ✅ | ⚠️ `retain-on-failure` only ⁶ | ⚠️ `retain-on-failure` only ⁷ | | Per-test `screenshot` / `video`, attached to Allure | ✅ | ✅ | ⚠️ produce-only ⁸ | ❌ ⁹ | | Cucumber Feature→Scenario→Step nesting | ⚠️ Scenario→Step ¹⁰ | ✅ | ⚠️ Feature→Scenario ¹¹ | ❌ ¹² | | Assertion capture (`captureAssertions`) | ✅ | ⚠️ `node:assert` only ¹³ | ⚠️ no `expect` ¹⁴ | ✅ | | BiDi console / network capture | ✅ auto | ✅ auto | ⚠️ opt-in ¹⁵ | ✅ auto | | A11y tab + pick-locator overlay (trace player) | ✅ | ✅ | ✅ | ✅ | | Transcript + Copy-for-LLM (trace player) | ✅ | ✅ | ✅ | ✅ | | One row per command in the Actions list | ✅ | ✅ | ✅ | ✅ | | Waits show as one row with what they issued nested under it | ✅ | ✅ | ⚠️ no element-wait polls ¹⁶ | ✅ | | Screenshot on every command row | ✅ | ✅ | ✅ | ✅ | | Browser console logs | ✅ | ✅ | ✅ | ✅ | | Source tab opens the test line that ran the command | ✅ | ✅ | ✅ | ✅ | | Metadata tab (session, capabilities, device) | ✅ | ✅ | ✅ | ✅ | | Performance timings on navigation rows | ✅ | ✅ | ✅ | ✅ | | Failed command in the Errors tab, with the browser's message | ✅ | ✅ | ✅ | ✅ | | Run, Rerun and Run all from the dashboard | ⚠️ no Cucumber step rerun ¹⁷ | ⚠️ no Cucumber step rerun ¹⁷ | ⚠️ no Cucumber step rerun ¹⁷ | ✅ | | Preserve & Rerun (compare a failed run with its rerun) | ✅ | ✅ | ✅ | ✅ | | Dashboard window opens by itself in live mode, and can be turned off | ⚠️ always opens ¹⁸ | ✅ `openUi: false` | ⚠️ always opens ¹⁹ | ✅ `DEVTOOLS_OPEN=0` | | Turn off per-command screenshots (`captureScreenshots`) | ❌ ²⁰ | ✅ | ❌ ²¹ | ❌ ²¹ | | Force the test browser headless (`headless`) | ❌ ²² | ⚠️ Chrome only ²³ | ❌ ²² | ❌ ²² | | Safari kept frontmost so input lands (live mode) | ⚠️ once ²⁴ | ✅ before each element input | ⚠️ once ²⁴ | ⚠️ once ²⁴ | | Unpacked trace output (`traceFormat: 'ndjson-directory'`) | ✅ | ✅ | ✅ | ❌ zip only ²⁵ | | Artifacts manifest for CI and reporters (`emitArtifactsManifest`) | ✅ | ✅ | ⚠️ opt-in ²⁶ | ❌ ²⁷ | | Network without BiDi (Safari, Appium mobile browsers) | ⚠️ ²⁸ | ⚠️ ²⁸ | ⚠️ ²⁸ | ⚠️ ²⁸ | ✅ supported. ⚠️ partial, with the limit in the note below. ❌ not supported. Each supported cell is backed by the cross-adapter conformance suite, a named test or a manual check, listed in [the feature list](https://github.com/webdriverio/devtools/blob/main/packages/conformance/src/features.ts). ¹ Without BiDi (Safari, Appium) the page collector is injected after each navigation, so a page the test leaves within tens of milliseconds is never captured. ² Without BiDi a page the test leaves within tens of milliseconds is never drained, so its requests are not listed. ³ Without BiDi (`bidi: true`) or Chrome's performance log (`goog:loggingPrefs`), a page the test leaves within tens of milliseconds is never drained, so its requests are not listed. ⁴ Nightwatch exposes no stable CDP handle, so frames come from a `takeScreenshot` poll every 200 ms. ⁵ Nightwatch fires the global `beforeEach` / `afterEach` once per test module for `describe/it` and exports-object tests, so they collapse to one slice keyed to the first test; Cucumber scenarios get real per-test slices. ⁶ For `describe/it` and exports-object tests, `--retries` reruns a testcase internally without firing the per-test hooks again, so the other policies behave like `retain-on-failure`; Cucumber scenarios record every attempt. ⁷ Nothing the Python adapter sends carries an attempt number, so the retry-aware policies behave like `retain-on-failure`. ⁸ Nightwatch has no live Allure attach API, so per-test screenshots and videos are written to disk and listed in the manifest but not attached. ⁹ The Python adapter has no `screenshot` / `video` options and no Allure attachment yet. ¹⁰ The service records no feature ancestry for a scenario, so the trace nests Scenario→Step. ¹¹ Nightwatch steps are not stamped as nested groups, so the trace nests Feature→Scenario. ¹² The Python adapter stamps no Feature or Step groups, so a pytest-bdd scenario is one flat test group with no Feature parent and no Step children. ¹³ `node:assert` rows pass and fail; jest-style `expect()` and chai produce no rows at all, and a failing matcher only marks its test failed. ¹⁴ `assert.*`, `verify.*` and `node:assert` rows pass and fail; Nightwatch's `expect` API produces no rows. ¹⁵ Nightwatch turns it on with `bidi: true` plus `webSocketUrl: true` in the capabilities. ¹⁶ A `waitUntil` row holds the commands its condition issued; a `waitForElement*` row has nothing under it, because Nightwatch polls for the element through its own transport rather than `browser`. ¹⁷ Under Cucumber a Gherkin step has no CLI filter of its own, so the dashboard reruns scenarios and features, not single steps. ¹⁸ The service always opens the dashboard in live mode; `devtoolsCapabilities` picks its browser but cannot skip it. ¹⁹ Nightwatch always opens the dashboard in live mode. ²⁰ No option: every command row takes a screenshot, except on Appium, where only native sessions in live mode do. ²¹ No option: every command row takes a screenshot. ²² No option: set headless in the browser capabilities, as for any run. ²³ The option adds `--headless=old` to `goog:chromeOptions` only, so other browsers stay headed; set their own headless capability. ²⁴ Brings Safari to the front once after the session starts (live mode, local macOS), so a click issued after another window took the front can still land nowhere. ²⁵ The Python adapter has no option for it and sends no format in its export request, so the backend writes a zip. ²⁶ Nightwatch has no live Allure signal to turn the manifest on by itself, so it stays opt-in. ²⁷ The Python adapter writes no artifacts manifest. ²⁸ Fetch and XHR calls carry headers and bodies; every other load comes from the page's Resource Timing buffer, with timing and size but no headers or body, and no status on Safari. --- Source: https://webdriver.io/docs/devtools/limitations.md # Trace Mode Limitations What [Trace Mode](/docs/devtools/wdio/trace-mode.md) deliberately skips, plus the known gaps across adapters. ## What trace mode skips[​](#what-trace-mode-skips "Direct link to What trace mode skips") * **DevTools UI window** — no Chrome instance opens for the dashboard. * **Backend port-bind**: the JavaScript adapters reserve no localhost port. The Python adapter still starts (or attaches to) the backend, because the backend builds its archive, but opens no window. * **`screencast.enabled`** — the live-mode continuous `.webm` recording is ignored in trace mode (a warning is logged). Trace mode instead records a dense [`filmstrip`](/docs/devtools/wdio/trace-mode.md#dense-filmstrip--filmstrip) into the archive **by default** (set `filmstrip: false` for one frame per action), plus per-test [`video`](/docs/devtools/wdio/trace-mode.md#per-test-screenshot--video--screenshot--video) slices when enabled. The screencast **tuning** fields (`quality`, `maxWidth`, `pollIntervalMs`, …) still apply to whichever recorder runs. * **`wdio-trace-<sessionId>.json` dump** — removed entirely. The legacy monolithic JSON the WDIO live mode used to write is gone; live mode now streams to the dashboard and writes nothing to disk, and the `trace.zip` is the single trace artifact. ## Known limitations[​](#known-limitations "Direct link to Known limitations") * **Nightwatch BDD `describe/it`** — `traceGranularity: 'test'` collapses to a **single session-scoped slice**: Nightwatch runs the individual `it`s internally without a per-test hook the plugin can see, so the slice keys to the first test. Metadata capture (per-testcase state in the manifest) is unaffected, but per-`it` trace/screenshot/video keying and retry-aware retention degrade to session scope for this interface. Nightwatch's **exports-object** and **Cucumber** interfaces expose per-scenario/per-test hooks and get real per-test slicing. (WebdriverIO mocha/cucumber and Selenium mocha are unaffected.) * **Nightwatch retry-aware retention** — only `retain-on-failure` works; other retry-aware policies degrade because Nightwatch re-runs a testcase internally on `--retries` without re-firing the per-test hooks. See [Retention](/docs/devtools/wdio/trace-mode.md#retention--tracepolicy). * **Nightwatch Allure attach** — per-test `screenshot`/`video` are produce-only (files + manifest), not attached inline; see [Allure integration](/docs/devtools/allure.md). * **WebdriverIO needs WebDriver BiDi** for page capture (Chrome 114+, Firefox 130+; enabled automatically). Appium sessions skip it; set `'wdio:enforceWebDriverClassic': true` there. * **Safari in live mode must stay the frontmost window**: Safari delivers synthesized clicks and keys only to its frontmost window and reports success either way, so input issued while the dashboard or any other window is in front reaches nothing. The Selenium (Node.js) adapter opens its dashboard behind Safari and brings the session's window forward before each input; the WebdriverIO service, Nightwatch and Python bring Safari to the front once after the session starts (macOS, local Safari only). Do not click into other windows, including the dashboard, while a live Safari run is in progress. Trace mode opens no window and is not affected. * **Network without BiDi**: on Safari and Appium sessions the Network tab comes from the page's own `fetch` / `XMLHttpRequest` patch and Resource Timing buffer, so loads the page did not make through `fetch` / XHR carry no headers or body, and on Safari no status. A native app session captures network only through the appium-interceptor plugin (`appium:intercept: true`, Android); see [Native app network](/docs/devtools/mobile.md#native-app-network). See [Network Logs](/docs/devtools/wdio/network-logs.md#without-webdriver-bidi). * **Hybrid apps**: only WebdriverIO follows a hybrid app into its webview, and a hybrid app's webview actions carry no per-action element data, A11y tree or settle screenshot. See [Mobile Testing](/docs/devtools/mobile.md). * **No redaction**: a trace records everything the run displayed or typed: DOM mutations, `fill` arguments, the transcript and the test source. Only password-field values are blanked in the element snapshot, and typed text still appears in the mutation stream. Treat a trace archive as being as sensitive as the run that produced it. * **Non-Chrome video/filmstrip** — on browsers without a CDP push path the recorder polls `takeScreenshot`, which adds WebDriver round-trips and (under Allure) floods the step log; pair with the reporter's step-silencing options. --- Source: https://webdriver.io/docs/devtools/wdio.md # WebDriverIO DevTools A WebdriverIO service that provides a developer tools UI for running, debugging, and inspecting browser automation tests. Features include DOM mutation replay, per-command screenshots, network request inspection, console log capture, and session screencast recording. ## Installation[​](#installation "Direct link to Installation") ``` npm install @wdio/devtools-service --save-dev ``` Requires Node.js 22.23.4+, 24.22.1+ or 26.12.1+, also with WebdriverIO v9. ## Usage[​](#usage "Direct link to Usage") ### Test Runner[​](#test-runner "Direct link to Test Runner") ``` // wdio.conf.ts export const config = { services: ['devtools'], } ``` ### Standalone[​](#standalone "Direct link to Standalone") ``` import { remote } from 'webdriverio' import { setupForDevtools } from '@wdio/devtools-service' const browser = await remote(setupForDevtools({ capabilities: { browserName: 'chrome' } })) await browser.url('https://example.com') await browser.deleteSession() ``` Requires a browser session with WebDriver BiDi (Chrome 114+, Firefox 130+), which WebdriverIO enables automatically. Appium sessions skip page capture that needs it; set `'wdio:enforceWebDriverClassic': true` in an Appium capability block (see [Mobile Testing](/docs/devtools/mobile.md)). ## Service Options[​](#service-options "Direct link to Service Options") ``` services: [['devtools', options]] ``` | Option | Type | Default | Description | | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `port` | `number` | `3000` (a free port is used if it is taken) | Port the DevTools UI server listens on | | `hostname` | `string` | `'localhost'` | Hostname the DevTools UI server binds to | | `devtoolsCapabilities` | `Capabilities` | Chrome 1600x1200 | Capabilities used to open the DevTools UI window | | `screencast` | `ScreencastOptions` | - | Session video recording ([see Screencast](/docs/devtools/wdio/screencast.md)) | | `mode` | `'live' \| 'trace'` | `'live'` | `live` opens the DevTools UI; `trace` skips it and writes a portable artifact instead ([see Trace Mode](/docs/devtools/wdio/trace-mode.md)) | | `traceFormat` | `'zip' \| 'ndjson-directory'` | `'zip'` | Trace artifact layout — single archive vs unpacked directory. Only applies when `mode: 'trace'` | | `traceGranularity` | `'session' \| 'spec' \| 'test'` | `'session'` | One trace per session / spec file / test. `'test'` writes each to `test-results/<spec>-<title>-<browser>[-retryN]/trace.zip`. Only applies when `mode: 'trace'` ([see Trace Mode](/docs/devtools/wdio/trace-mode.md#trace-granularity--tracegranularity)) | | `tracePolicy` | `'on' \| 'retain-on-failure' \| 'retain-on-first-failure' \| 'on-first-retry' \| 'on-all-retries' \| 'retain-on-failure-and-retries'` | `'on'` | Which traces to keep. Pairs with `traceGranularity: 'test'`. Only applies when `mode: 'trace'` | | `filmstrip` | `boolean` | `true` | Records a dense, continuous screencast filmstrip *into* the trace for smooth scrubbable playback in the player — dense frames alongside the per-action frames, thinned and content-addressed at export. Only applies when `mode: 'trace'` | | `screenshot` | `'off' \| 'on' \| 'only-on-failure'` | `'off'` | Per-test screenshot, attached inline to Allure (`image/png`). Requires `mode: 'trace'` + `traceGranularity: 'test'` | | `video` | `'off' \| TraceRetentionPolicy` | `'off'` | Per-test screencast video, retained per the given policy and attached inline to Allure (`video/webm`). Requires `mode: 'trace'` + `traceGranularity: 'test'` | | `emitArtifactsManifest` | `boolean` | `false` | Writes `devtools-artifacts-<sessionId>.json` — a generic index of every produced artifact plus each test's state, for reporters/CI. Auto-enabled when `@wdio/allure-reporter` is in the config. Only applies when `mode: 'trace'` | | `captureAssertions` | `boolean` | `true` | Capture assertions as trace action rows — `node:assert` plus passing/failing `expect(...)` matchers. Set `false` to opt out | ## Runtime snapshot[​](#runtime-snapshot "Direct link to Runtime snapshot") The service adds a `browser.getSnapshot()` command that returns an AI-readable accessibility tree of the current page (`text`) plus an `elements` map from short refs (`e1`, `e2`, …) to selectors: ``` const { text, elements } = await browser.getSnapshot({ inViewportOnly: true }) ``` It reads the live page directly, with no trace-mode overhead. Its locators always use portable CSS / XPath, so a text locator can differ from the WebdriverIO-dialect one the trace player's A11y tab shows. ## Getting Started[​](#getting-started "Direct link to Getting Started") 1. Run your WebdriverIO tests 2. The DevTools UI automatically opens in an external browser window 3. Tests begin executing immediately with real-time visualization 4. View live browser preview, test progress, and command execution 5. After initial run completes, use play buttons to rerun individual tests or suites 6. Click stop button anytime to terminate running tests 7. Explore actions, metadata, console logs, and source code in the workbench tabs ## Features[​](#features "Direct link to Features") Explore the WebDriverIO DevTools features in detail: * **[Interactive Test Rerunning & Visualization](/docs/devtools/wdio/interactive-test-rerunning.md)** - Real-time browser previews with test rerunning * **[Preserve & Rerun (Compare)](/docs/devtools/wdio/preserve-and-rerun.md)** - Snapshot a failing test, rerun it, and diff the two runs side-by-side * **[Multi-Framework Support](/docs/devtools/wdio/multi-framework-support.md)** - Works with Mocha, Jasmine, and Cucumber * **[Console Logs](/docs/devtools/wdio/console-logs.md)** - Capture and inspect browser console output * **[Network Logs](/docs/devtools/wdio/network-logs.md)** - Monitor API calls and network activity * **[Metadata](/docs/devtools/wdio/metadata.md)** - Session capabilities, environment, and timing per browser session * **[TestLens](/docs/devtools/wdio/testlens.md)** - Navigate to source code with intelligent code navigation * **[Session Screencast](/docs/devtools/wdio/screencast.md)** - Automatic video recording of browser sessions * **[Trace Mode](/docs/devtools/wdio/trace-mode.md)** - Headless capture path producing a portable `trace.zip` artifact (no UI window); supports `zip` and `ndjson-directory` output formats, per-session/spec/test granularity, retry-aware retention policies, and an optional dense `filmstrip`, all viewable in the first-party `show-trace` player ## Trace Player[​](#trace-player "Direct link to Trace Player") A trace recorded with `mode: 'trace'` opens in the first-party `show-trace` player (`npx show-trace path/to/trace.zip`) — DOM time-travel, the A11y tab and pick-locator element overlay, the Transcript tab with Copy-for-LLM, the Errors / Console / Network / Source tabs, and a scrubbable timeline (dense filmstrip, Cucumber Scenario → Step nesting). See the **[Trace Player](/docs/devtools/trace-player.md)** page for the full walkthrough and other compatible viewers. ## Allure Reporting[​](#allure-reporting "Direct link to Allure Reporting") With `@wdio/allure-reporter` in the config, trace-mode artifacts (the trace zip, plus the per-test screenshot and video at `traceGranularity: 'test'`) attach to the Allure report automatically, and `emitArtifactsManifest` is auto-enabled. See **[Allure Integration](/docs/devtools/allure.md)** for the attachment details and the reporter step-silencing options. --- Source: https://webdriver.io/docs/devtools/selenium.md # Selenium DevTools Selenium WebDriver adapter for [WebdriverIO DevTools](https://github.com/webdriverio/devtools) - brings the same visual debugging UI to any Selenium test, in **Node.js** or **Python**, regardless of the test runner. Node.js works with **Mocha**, **Jest**, **Cucumber**, or a plain script - the plugin auto-detects the runner and wires test boundaries accordingly. Python works with **pytest** or a plain script, and under pytest needs no changes to your test files at all. Pick your language in the tabs below; the choice follows you down the page. ## Installation[​](#installation "Direct link to Installation") * Node.js * Python ``` npm install @wdio/selenium-devtools ``` Requires Node.js 22.23.4+, 24.22.1+ or 26.12.1+ and `selenium-webdriver` 4.8 or later. Encoding a screencast `.webm` needs `ffmpeg` on `PATH`. ``` pip install selenium-devtools-py ``` **Requires Python 3.10+ and `selenium>=4.44`.** Both are declared in the package metadata, so pip enforces them rather than leaving you to find an empty Network tab at runtime. Network capture subscribes through the public BiDi event API that selenium regenerated in 4.44; the private connection it replaced was removed in the same release, and 4.44 is what sets the Python floor. Then install the backend, once: ``` selenium-devtools install-backend ``` pip cannot do this for you: a wheel has no install hook, and the backend is a Node package. Skip it and runs still work, falling back to fetching `@wdio/devtools-backend` with `npx` on first use. That fallback costs a registry round trip on every run and fails mid-session if a proxy declines the package. `selenium-devtools backend-path` says whether the backend is installed, `install-backend --force` reinstalls a broken one, and `uninstall-backend` removes it. The install goes under `$XDG_CACHE_HOME` (default `~/.cache`). A `chromedriver` on `PATH` that does not match your Chrome breaks every Selenium run; with none on `PATH`, Selenium Manager resolves a matching one. ## Setup[​](#setup "Direct link to Setup") * Node.js * Python The minimum is one import, `import '@wdio/selenium-devtools'`, in your test file. Under Mocha, Jest and Cucumber nothing else is needed; `DevTools.configure(...)` is optional and only changes defaults. Each block below is a **complete, copy-paste-ready example** including the `DevTools.configure(...)` call. Pick the runner you use, drop the snippet into your project, and run it. ### Mocha[​](#mocha "Direct link to Mocha") ``` // tests/example.test.js import { strict as assert } from 'node:assert' import { Builder, By, until } from 'selenium-webdriver' import { DevTools } from '@wdio/selenium-devtools' DevTools.configure({ screencast: { enabled: true, quality: 70, maxWidth: 1280, maxHeight: 720 } }) describe('smoke test', function () { let driver before(async function () { driver = await new Builder().forBrowser('chrome').build() }) after(async function () { if (driver) { await driver.quit() } }) it('loads the login page and reads the heading', async function () { await driver.get('https://the-internet.herokuapp.com/login') const heading = await driver.wait(until.elementLocated(By.css('h2')), 10000) assert.equal(await heading.getText(), 'Login Page') }) }) ``` Run it: ``` mocha --timeout 60000 tests/example.test.js ``` > Alternative: skip the per-file import and use `mocha --require @wdio/selenium-devtools` to load the plugin once for the whole run. You still need a one-time `DevTools.configure(...)` call somewhere if you want non-default options. ### Jest[​](#jest "Direct link to Jest") ``` // test/example.js import { DevTools } from '@wdio/selenium-devtools' import { Builder, By, until } from 'selenium-webdriver' DevTools.configure({ screencast: { enabled: true, quality: 70, maxWidth: 1280, maxHeight: 720 } }) describe('login flow', () => { let driver beforeEach(async () => { driver = await new Builder().forBrowser('chrome').build() }, 60000) afterEach(async () => { if (driver) { await driver.quit() } }) test('logs in with valid credentials', async () => { await driver.get('https://the-internet.herokuapp.com/login') await driver.findElement(By.id('username')).sendKeys('tomsmith') await driver.findElement(By.id('password')).sendKeys('SuperSecretPassword!') await driver.findElement(By.css('button[type="submit"]')).click() await driver.wait(until.urlContains('/secure'), 10000) const flash = await driver.findElement(By.id('flash')) expect(await flash.getText()).toMatch(/You logged into a secure area/i) }, 60000) }) ``` `jest.config.json`: ``` { "testEnvironment": "node", "testMatch": ["<rootDir>/test/example.js"], "testTimeout": 60000, "transform": {} } ``` Run it (ESM needs the experimental flag): ``` NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.json ``` ### Cucumber[​](#cucumber "Direct link to Cucumber") Cucumber's split layout means three small files - one to load the plugin, one for World/hooks, and one for step definitions. `features/support/setup.js` - load the plugin and configure once: ``` import { DevTools } from '@wdio/selenium-devtools' DevTools.configure({ screencast: { enabled: true, quality: 70, maxWidth: 1280, maxHeight: 720 } }) ``` `features/support/world.js` - driver lifecycle: ``` import { setWorldConstructor, World, Before, After, setDefaultTimeout } from '@cucumber/cucumber' import { Builder } from 'selenium-webdriver' setDefaultTimeout(60000) class CustomWorld extends World { constructor (options) { super(options) this.driver = null } } setWorldConstructor(CustomWorld) Before(async function () { this.driver = await new Builder().forBrowser('chrome').build() }) After(async function () { if (this.driver) { await this.driver.quit() this.driver = null } }) ``` `cucumber.json` - wire the setup file in **first** so the plugin patches Selenium before any step runs: ``` { "default": { "import": [ "features/support/setup.js", "features/support/world.js", "features/support/steps.js" ], "paths": ["features/*.feature"], "format": ["progress"] } } ``` Run it: ``` cucumber-js --config cucumber.json ``` ### Plain Node script (no test runner)[​](#plain-node-script-no-test-runner "Direct link to Plain Node script (no test runner)") If you run `node tests/google.test.js` directly there's no runner for the plugin to auto-hook. By default you get a single "Selenium Session" test in the dashboard, standing for the whole script: when the script ends it is closed as passed (or keeps the state it already had) and its suite is finalized, so the dashboard shows the run as finished. A script that quits its driver and builds another is still that one test. To get a named test boundary, call `DevTools.startTest` / `endTest` around your work; a test opened with `startTest` is closed by your own `endTest`, not at script end: ``` // tests/google.test.js import { DevTools } from '@wdio/selenium-devtools' import { Builder, By, until, Key } from 'selenium-webdriver' DevTools.configure({ screencast: { enabled: true, quality: 70, maxWidth: 1280, maxHeight: 720 }, headless: false }) async function run () { DevTools.startTest('search Google for Selenium') // optional - names the test row const driver = await new Builder().forBrowser('chrome').build() try { await driver.get('https://www.google.com') const searchBox = await driver.findElement(By.name('q')) await searchBox.sendKeys('Selenium WebDriver JavaScript', Key.ENTER) await driver.wait(until.titleContains('Selenium'), 10000) DevTools.endTest('passed') } catch (err) { DevTools.endTest('failed') throw err } finally { await driver.quit() } } run() ``` ``` node tests/google.test.js ``` > Only use `startTest` / `endTest` for plain Node scripts. Under Mocha / Jest / Cucumber the plugin already knows when each test starts and ends - calling these manually would create duplicate rows. ### pytest[​](#pytest "Direct link to pytest") Nothing goes in your test files - the plugin is auto-discovered, and a flag turns it on for the run: ``` pytest --devtools tests/ # live dashboard pytest --devtools-trace tests/ # write a trace archive instead (implies --devtools) ``` Or commit the choice, so nobody has to remember the flag: pyproject.toml ``` [tool.pytest.ini_options] devtools = true # devtools_trace = true # trace archive instead of a dashboard # devtools_trace_granularity = "test" # ... one archive per test # devtools_trace_policy = "retain-on-failure" # ... keeping only what failed ``` A `pytest.ini` with a `[pytest]` section takes the same keys. The two trace settings are covered under [How many archives, and which ones to keep](#how-many-archives-and-which-ones-to-keep). Capture is always opt-in - installing the package must never change how an existing suite behaves. All that differs is *how* you say yes: | How you opt in | Scope | | ------------------------------------------------------------------------------------------------ | ------------------- | | `--devtools` / `--devtools-trace` | this run | | `devtools` / `devtools_trace` in `[tool.pytest.ini_options]` | this project | | `DEVTOOLS_ENABLE=1` (or `DEVTOOLS_PORT=<n>`, which also attaches to a dashboard already running) | this shell - for CI | Highest wins: CLI, then ini, then environment. `pytest -o devtools=false` turns a project default off for a single run, which is why there is no `--no-devtools`. `DEVTOOLS_TRACE=1` picks trace mode but does **not** switch capture on by itself, so exporting it for your own scripts never captures a pytest run you did not ask for. In live mode the dashboard opens in a dedicated browser window and **stays open after the run** so you can inspect what happened; close it (or `Ctrl-C`) to finish. Two kinds of run stay uncaptured even when you opt in: `--collect-only`, where nothing executes, and a run that collected no tests - a mistyped path would otherwise park your terminal on an empty dashboard. ### Plain Python script (no test runner)[​](#plain-python-script-no-test-runner "Direct link to Plain Python script (no test runner)") Two lines around your existing Selenium code: login.py ``` import selenium_devtools as devtools from selenium import webdriver devtools.enable() # open the dashboard, capture every command # devtools.enable(trace=True) # or: write a trace.zip and open no window driver = webdriver.Chrome() driver.get('https://the-internet.herokuapp.com/login') driver.find_element('id', 'username').send_keys('tomsmith') driver.quit() devtools.wait_for_dashboard_close() # keep the UI up to inspect (no-op when no window is open) devtools.disable() ``` If the backend cannot be launched or reached, `enable()` logs a warning and returns `None`. Capture is skipped and your tests still run - a missing dashboard never fails a suite. ### Parallel runs (`pytest -n`)[​](#parallel-runs-pytest--n "Direct link to parallel-runs-pytest--n") **pytest-xdist works with no extra configuration.** Every process reporting into one run has to agree on a run id, or the backend treats each connect as a new run and wipes what the previous one captured. With xdist they do agree: the plugin loads in the **controller** as well, and enabling capture there resolves the id before xdist spawns any worker - workers are child processes, so they inherit it. What genuinely reads as separate runs: two independent `pytest` invocations, or a worker started without the environment. Export `DEVTOOLS_RUN_ID` yourself to join such processes into one run. ### Run controls (Run, Rerun, Run-all)[​](#run-controls-run-rerun-run-all "Direct link to Run controls (Run, Rerun, Run-all)") All three work under pytest and for a plain script. A rerun is not a message to the running process: the backend spawns a fresh one from a command the adapter publishes at startup, and a control it cannot service stays disabled with a reason. * Under pytest each control selects its row by **nodeid** (`file.py`, `file.py::Class`, `file.py::Class::test`), using the interpreter that ran your tests. For a plain script all three relaunch the script. * Options that narrow a run are dropped from a targeted rerun: `-k`, `-m`, `--deselect`, `--lf`/`--ff`/`--sw`, and `-n`/`--dist`. A surviving filter could only narrow the named test to nothing, which pytest reports as a clean exit. * The rerun spawns in pytest's **rootdir**, and positional paths in the Run-all command are made absolute. An option carrying a *relative* path (`-c`, `--junitxml`) resolves against rootdir on a rerun. * A rerun reports into **the dashboard you pressed the button in** and opens no second window. Run-all keeps your original invocation even after a targeted rerun. Two limits: a dashboard that was already running when you connected keeps the directory it was started in, and under `pytest -n` the dashboard's state belongs to whichever worker connected last. ### Preserve & Rerun[​](#preserve--rerun "Direct link to Preserve & Rerun") A failed row carries a second button beside Rerun. It snapshots the attempt, reruns the test, and the **Compare** tab diffs the two: commands, console and network side by side. The snapshot is taken before the rerun starts; preserving after a new run has connected is refused (HTTP 409). A plain Rerun drops every baseline, so the Compare tab disappears after an ordinary rerun. ## Configuration Options[​](#configuration-options "Direct link to Configuration Options") * Node.js * Python | Option | Type | Default | Description | | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `port` | `number` | `3000` | Port for the DevTools backend server. Auto-incremented if already in use. | | `hostname` | `string` | `'localhost'` | Hostname the backend server binds to. | | `openUi` | `boolean` | `true` | Auto-open the DevTools UI in a new Chrome window. Set `false` for CI. | | `captureScreenshots` | `boolean` | `true` | Capture a screenshot after every successful WebDriver command. | | `headless` | `boolean` | `false` | Run the **test** browser headless (injects `--headless=old`). The DevTools UI window is unaffected. | | `screencast` | `ScreencastOptions` | `{ enabled: false }` | Per-session `.webm` video recording. Options match the [WebdriverIO Screencast](/docs/devtools/wdio/screencast.md) page. | | `rerunCommand` | `string` | auto | Command template for per-test rerun. `{{testName}}` is substituted. Auto-derived from runner argv if omitted. | | `mode` | `'live' \| 'trace'` | `'live'` | `live` opens the DevTools UI; `trace` skips it and writes a portable artifact instead. See [Trace Mode](/docs/devtools/wdio/trace-mode.md). Overrides `openUi`. | | `traceFormat` | `'zip' \| 'ndjson-directory'` | `'zip'` | Trace artifact layout. Only applies when `mode: 'trace'`. | | `traceGranularity` | `'session' \| 'spec' \| 'test'` | `'session'` | One trace per session / spec file / test. `'test'` writes each to `test-results/<spec>-<title>-<browser>[-retryN]/trace.zip`. Only applies when `mode: 'trace'`. See [Trace Mode](/docs/devtools/wdio/trace-mode.md#trace-granularity--tracegranularity). | | `tracePolicy` | `'on' \| 'retain-on-failure' \| 'retain-on-first-failure' \| 'on-first-retry' \| 'on-all-retries' \| 'retain-on-failure-and-retries'` | `'on'` | Which traces to keep. Pairs with `traceGranularity: 'test'`. Only applies when `mode: 'trace'`. | | `filmstrip` | `boolean` | `true` | Record a dense, continuous screencast into the trace for frame-by-frame scrubbing in the player. Only applies when `mode: 'trace'`. | | `screenshot` | `'off' \| 'on' \| 'only-on-failure'` | `'off'` | Trace mode + `traceGranularity: 'test'`. Per-test screenshot, attached inline to Allure (`image/png`) via `allure-js-commons` when an Allure runner adapter is active. | | `video` | `'off' \| TraceRetentionPolicy` | `'off'` | Trace mode + `traceGranularity: 'test'`. Per-test screencast video, retained per the given policy, attached inline to Allure (`video/webm`) via `allure-js-commons` when an Allure runner adapter is active. | | `emitArtifactsManifest` | `boolean` | auto | Write the `devtools-artifacts-<sessionId>.json` manifest — the generic index reporters/CI consume to discover produced artifacts — next to the trace. Off by default; **auto-enables** when an `allure-js-commons` runtime is active. Trace mode only. | | `captureAssertions` | `boolean` | `true` | Capture `node:assert` assertions (both passing and failing) as trace action rows. Set `false` to opt out. | ``` DevTools.configure({ port: 3000, hostname: 'localhost', headless: false, openUi: true }) ``` > `port` and `hostname` only take effect before the backend starts, which happens when the first driver is built, so call `DevTools.configure(...)` before that; a later call ignores them with a warning. A rerun keeps its parent's backend whatever they say. > **For CI**, set both `headless: true` (hide the test browser) and `openUi: false` (don't try to open the dashboard window - CI environments have no display). The backend keeps running on the configured port so you can still open the UI later if needed. There is no options object - nothing devtools-specific has to appear in your test code. Under pytest you configure the adapter the way you configure pytest; a script passes keyword arguments to `enable()`; anything without a flag is an environment variable. | pytest flag | `[tool.pytest.ini_options]` | Effect | | ---------------------------------------------- | --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `--devtools` | `devtools = true` | Capture this run and open the dashboard. | | `--devtools-trace` | `devtools_trace = true` | Capture this run and write a trace archive instead of opening a dashboard. Implies `--devtools`. | | `--devtools-trace-granularity <session\|test>` | `devtools_trace_granularity = test` | One archive for the whole run (`session`, the default) or one per test. Implies `--devtools-trace`, unless an explicit `devtools_trace` value outranks it (see [the precedence table](#how-many-archives-and-which-ones-to-keep)). | | `--devtools-trace-policy <policy>` | `devtools_trace_policy = "retain-on-failure"` | Which archives are worth keeping. Implies `--devtools-trace` in the same way. See [How many archives, and which ones to keep](#how-many-archives-and-which-ones-to-keep). | Highest wins: CLI, then ini, then the environment below. `pytest -o devtools=false` turns a project default off for one run, and `pytest -o devtools_trace_policy=on` does the same for any of the others. | Variable | Effect | | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | `DEVTOOLS_ENABLE=1` | Turn capture on, when no flag or ini option already did. | | `DEVTOOLS_PORT=<n>` | Attach to a dashboard already listening on this port; also opts in. | | `DEVTOOLS_HOST=<host>` | Host the dashboard is reached on (default `localhost`). | | `DEVTOOLS_TRACE=1` | Write a trace archive instead of opening a dashboard. Selects the mode for a plain script; under pytest it does not opt the run in by itself. | | `DEVTOOLS_TRACE_GRANULARITY=<session\|test>` | Trace mode: one archive for the whole run, or one per test. Ambient, so it never selects trace mode by itself - pair it with `DEVTOOLS_TRACE=1`. | | `DEVTOOLS_TRACE_POLICY=<policy>` | Trace mode: which archives are worth keeping. Ambient, so it never selects trace mode by itself - pair it with `DEVTOOLS_TRACE=1`. | | `DEVTOOLS_FILMSTRIP=0` | Trace mode: leave the dense filmstrip out of the archive. | | `DEVTOOLS_A11Y=0` | Trace mode: skip the per-action A11y tree and element rects. | | `DEVTOOLS_OPEN=0` | Do not open the dashboard window (CI). | | `DEVTOOLS_BIDI=0` | Disable BiDi, and with it console and network capture. | | `DEVTOOLS_RUN_ID=<id>` | Join several processes into one run. | | `DEVTOOLS_BACKEND_CMD=<cmd>` | Start the backend with an explicit command instead of the resolved one. | Set for you rather than by you (listed so an unexpected value is recognisable): `DEVTOOLS_RUNNER_CWD`, `DEVTOOLS_APP_REUSE` / `DEVTOOLS_APP_HOST` / `DEVTOOLS_APP_PORT`, and `DEVTOOLS_RERUN_LAUNCH_COMMAND`. The backend is a Node application, so **Node.js 22.23.4+, 24.22.1+ or 26.12.1+ must be available in every mode** (the first releases with the CA store fix for the eMudhra intermediate CA compromise; the odd lines 23 and 25 are refused) - even in trace mode, where no dashboard window ever opens. It is not only the UI: the page collector is served by the backend, the whole event stream travels over its WebSocket, and in trace mode it is also what builds the archive. `enable()` checks for Node up front and names what is missing rather than failing later as a spawn timeout. The adapter finds or launches the backend for you, in this order: a backend that spawned this run as a rerun, then `DEVTOOLS_PORT` (attach), then `DEVTOOLS_BACKEND_CMD`, then the backend installed by `selenium-devtools install-backend`, then `npx @wdio/devtools-backend@<pinned version>`. The pin is fixed per adapter release so the backend always speaks the adapter's wire contract. The backend also serves the page scripts the adapter runs after each command (the collector's readiness probe, its injection and drain, and the navigation timing read), so the scripts are the same ones the Node.js adapters run. A backend you start yourself or attach to with `DEVTOOLS_PORT` or `DEVTOOLS_BACKEND_CMD` must be at least as new as the adapter's pinned version: against an older one the run logs a warning and continues with DOM replay and navigation timings off. See [running the backend on its own](/docs/devtools/dashboard.md#running-the-backend-on-its-own) if you would rather manage it yourself, or point `DEVTOOLS_PORT` at one you are already running, in which case no local Node is needed. ### Assertions[​](#assertions "Direct link to Assertions") Passing and failing `assert` statements appear as rows carrying **expected** and **actual**, and failures reach the Errors tab. Python's `assert` is a statement rather than a call, so unlike the Node adapter's `node:assert` patching there is nothing to wrap - the outcome comes from the runner. An assertion row also names the element its value was read from, so selecting the row boxes that element: `assert heading.text == "Secure Area"` carries the locator `heading` was found by, and so does a value from `get_attribute`, `is_displayed` or any other element read. Only a read made earlier in the same test counts. A value read from the page itself, such as `driver.title` or `driver.current_url`, names no element, even when some element's text reads the same. **Under pytest**, values come from the assertion rewriter, so every row carries real operands. Capturing *passing* assertions needs pytest's `enable_assertion_pass_hook`, which the plugin switches on for itself. One caveat: pytest decides per module, *while rewriting it*, whether to emit that hook, so a module whose rewritten bytecode was cached before the plugin was installed keeps reporting failures only. The adapter says so once at collection and names the cache to delete - which is **not** always the `__pycache__` beside your tests, since `sys.pycache_prefix` (set by default on macOS's system Python) sends every rewritten module to one central tree. **In a plain script** there is no rewriter, so outcomes come from the interpreter's line events and values are read from the frame about to run the assert. Only reads that cannot execute your code are resolved: a literal or a local resolves, an attribute or a call does not, because evaluating `driver.current_url` a second time would issue another WebDriver command. An assertion whose observed value could not be read this way names no element, since guessing from the expected value alone could box an element that once read the same text. ## Trace mode[​](#trace-mode "Direct link to Trace mode") Headless capture path, in **both languages** - no DevTools UI window opens, and the run writes a portable trace archive into a `test-results/` folder, with the same shape as the WebdriverIO trace artifact. The two differ only in how much of the artifact you can tune, and in who builds it. * Node.js * Python At session end the adapter writes `trace-<sessionId>.zip` (or a directory) itself, into `test-results/` next to the resolved test / config directory. ``` DevTools.configure({ mode: 'trace', traceFormat: 'ndjson-directory' // optional; default 'zip' }) ``` The backend port-bind, UI window, and `screencast` option are all skipped in trace mode. For the full feature reference (artifact contents, viewer, mobile testing, when to pick `zip` vs `ndjson-directory`), see the [Trace Mode page](/docs/devtools/wdio/trace-mode.md). ### Per-test artifacts and retention[​](#per-test-artifacts-and-retention "Direct link to Per-test artifacts and retention") At `traceGranularity: 'test'` each test gets its own artifact folder, and `tracePolicy` decides which are kept (e.g. `retain-on-failure`). In that mode you can also capture a per-test `screenshot` (PNG) and `video` (`.webm`), and enable a dense `filmstrip` recorded into the trace for frame-by-frame scrubbing. When an `allure-js-commons` runner adapter is active, per-test traces / screenshots / videos are attached inline to the Allure report (and `emitArtifactsManifest` auto-enables); otherwise they're written to `test-results/` and recorded in the manifest. ``` DevTools.configure({ mode: 'trace', traceGranularity: 'test', tracePolicy: 'retain-on-failure', filmstrip: true, screenshot: 'only-on-failure', video: 'retain-on-failure' }) ``` There is no options object to set - a flag under pytest, a keyword argument in a script: ``` pytest --devtools-trace tests/ # implies --devtools DEVTOOLS_TRACE=1 python3 login.py # plain script; same as devtools.enable(trace=True) ``` login.py ``` devtools.enable(trace=True) # write a trace.zip instead of opening a dashboard ``` The archive lands in `test-results/` beside the test file the first captured command came from - the same directory screencast videos already write to - named `trace-<sessionId>.zip`, or named after each test when you ask for [one archive per test](#how-many-archives-and-which-ones-to-keep). When no command carried a source location of yours, it falls back to `test-results/` under the current directory. **No dashboard window opens.** The artifact is the output, and a live run blocks on the window until you close it - a window would turn writing a file into an interactive session. The backend still starts, because it is what *builds* the archive: the trace transforms are TypeScript, so a Python run asks the backend for them rather than shipping a second copy of them. That is the one way this differs from the Node.js adapter's backend-free trace mode, and the reason [Node.js 22.23.4+, 24.22.1+ or 26.12.1+ is required in every mode](#configuration-options). Beyond the command rows, per-command screenshots and selectors, console and network that both modes capture, the archive carries: | In the archive | Default | Opt out | | --------------------------------------------------------------------------------------------- | ------- | ---------------------- | | DOM time-travel - the mutation stream the player replays step by step | on | - | | Dense filmstrip - the screencast frames, carried into the trace instead of a `.webm` | on | `DEVTOOLS_FILMSTRIP=0` | | A11y tree and element overlay - read beside each action, at two extra round trips per command | on | `DEVTOOLS_A11Y=0` | Trace mode encodes no `.webm`, so it needs no `ffmpeg` - the frames *are* the filmstrip. **The export is requested when the run finishes, not when the process exits** - pytest asks at `sessionfinish` and a script's `disable()` exports before it closes the transport, so CI gets the artifact whether or not a window was ever involved. ### How many archives, and which ones to keep[​](#how-many-archives-and-which-ones-to-keep "Direct link to How many archives, and which ones to keep") Two settings decide that, and neither means anything outside trace mode. **Granularity** - how many archives the run writes: | `--devtools-trace-granularity` | Result | | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | | `session` (default) | One archive for the whole run. | | `test` | One archive per test, each holding only that test's own commands, console, network, DOM mutations, a11y trees and screencast frames. | There is deliberately no `spec` value here. This adapter's spec *is* its test file, so a third name could only quietly mean one of the two above. **Policy** - which of those archives are kept: | `--devtools-trace-policy` | Result | | ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | | `on` (default) | Keep everything. | | `retain-on-failure` | Keep only what failed. | | `retain-on-first-failure`, `on-first-retry`, `on-all-retries`, `retain-on-failure-and-retries` | Accepted, but today they behave **exactly like `retain-on-failure`**. | Those last four are not retry-aware yet, and it is worth saying plainly rather than discovering it from an archive you expected: nothing this adapter puts on the wire carries an attempt number, so a retried test overwrites its own earlier outcome and the retry-aware question cannot be asked at all. The backend logs the degradation rather than pretending otherwise. Pick one only if you want `retain-on-failure` under a name that will mean more later. The two combine: | Granularity | Policy | What you get | | ----------- | ------------------- | -------------------------------------------------- | | `test` | `retain-on-failure` | Only the tests that failed. | | `session` | `retain-on-failure` | The whole run's archive, if anything in it failed. | | either | `on` | Everything. | Each archive kept at `test` granularity is named after its test (`trace-<test>-<hash>.zip`, the hash taken from the test's nodeid so two parametrised cases sharing a title cannot overwrite each other). A run that keeps nothing writes nothing at all, which is the point - the archives you are left with are the ones worth opening, and a declined export is the policy working rather than a failure. Set them for one run: ``` pytest --devtools-trace-granularity test --devtools-trace-policy retain-on-failure tests/ ``` Or commit them, so a contributor who clones the project captures the same way without being told: pytest.ini ``` [pytest] devtools_trace = true devtools_trace_granularity = test devtools_trace_policy = retain-on-failure ``` `[tool.pytest.ini_options]` in `pyproject.toml` takes the same keys, and `pytest -o devtools_trace_policy=on tests/` overrides one of them for a single run without editing the file. A fully commented version - every setting and every environment variable, with what each one is for - is in the repo at [`examples/selenium-py/pytest/`](https://github.com/webdriverio/devtools/tree/main/examples/selenium-py/pytest). A plain script passes the same two as keyword arguments: login.py ``` devtools.enable(trace_granularity='test', trace_policy='retain-on-failure') ``` **Naming either one explicitly selects trace mode.** The CLI flag, the ini option and the `enable()` argument all imply it, since a policy or a granularity means nothing in live mode and honouring one without the mode would silently drop what you asked for. `DEVTOOLS_TRACE_POLICY` and `DEVTOOLS_TRACE_GRANULARITY` deliberately do **not**: an exported variable is ambient and may have been set for a different script in the same shell, so flipping a live run to trace mode on that basis would take away the dashboard nobody asked to lose - pair them with `DEVTOOLS_TRACE=1`. A run that ends up ignoring an exported trace setting logs a warning, rather than leaving you to notice an archive that never appeared. Under pytest, an explicit `devtools_trace` value outranks that implication at its own level and below, so `pytest -o devtools_trace=false` gets a live run out of a project whose ini file commits a policy or a granularity. The command line (the `--devtools-trace*` flags and `-o`) is one level, the ini file the next, and the first row below that applies decides: | Trace mode is decided by | Result | | ------------------------------------------------------------------------------ | ------------------------------------------------- | | `--devtools-trace` | on | | `-o devtools_trace=<bool>` | that value | | `--devtools-trace-policy` / `--devtools-trace-granularity`, or `-o` for either | on | | `devtools_trace` in the ini file | that value | | a policy or granularity in the ini file | on | | `DEVTOOLS_TRACE` | read by `enable()` when none of the above decided | There is no flag for "trace off", so `-o devtools_trace=false` is how the command line says it. A policy or granularity left without trace mode has no effect, does not switch capture on by itself, and the run logs one warning naming it. ### Viewing the trace[​](#viewing-the-trace "Direct link to Viewing the trace") Open any trace `.zip` in the first-party player — the same DevTools UI in a dedicated **player** mode: ``` npx show-trace path/to/trace.zip # in a project that installs the adapter pnpm show-trace path/to/trace.zip # from the devtools monorepo ``` The `show-trace` bin ships with `@wdio/selenium-devtools`, so it's available in any project that installs it — no extra dependency. A Python project installs no Node.js adapter, but the same player ships with the backend the adapter already fetches for you: `npx -p @wdio/devtools-backend show-trace path/to/trace.zip`. Because the Selenium adapter captures the page's **DOM mutation stream** and a per-command element / accessibility snapshot alongside each screenshot, a Selenium trace drives the player's full feature set — DOM time-travel, the A11y tab and pick-locator overlay, the Transcript tab with Copy-for-LLM, Cucumber Feature → Scenario → Step nesting, and the scrubbable timeline. A Python trace carries the same mutation stream and per-action snapshot (the element / a11y read is trace mode only there, and on by default); the Gherkin nesting is the one entry that has no pytest equivalent. The trace uses a portable NDJSON schema, so the same `.zip` (or directory) also opens in other compatible trace viewers. See the **[Trace Player](/docs/devtools/trace-player.md)** page for the full walkthrough. ## Public API[​](#public-api "Direct link to Public API") * Node.js * Python ``` import { DevTools } from '@wdio/selenium-devtools' DevTools.configure(opts) // set runtime options (see above) DevTools.startTest(name, meta?) // mark a named test boundary (plain Node scripts only) DevTools.endTest('passed'|'failed'|'skipped'|'pending') ``` Under Mocha / Jest / Cucumber the plugin auto-hooks the runner's lifecycle, so you don't need `startTest` / `endTest` manually - calling them would create duplicate rows. ``` import selenium_devtools as devtools devtools.enable() # connect and instrument; idempotent devtools.disable() # tear down; safe to call twice devtools.wait_for_dashboard_close() # block until the window is closed devtools.get_capturer() # the live SessionCapturer, or None devtools.dashboard_url() # the URL the dashboard is served on devtools.export_trace() # write the trace archive now (trace mode only) ``` `enable()` takes an optional `host` and `port`, plus keyword arguments: ``` devtools.enable(trace=True) # write a trace.zip; open no window devtools.enable(trace=True, filmstrip=False) # ... without the dense filmstrip devtools.enable(trace=True, a11y=False) # ... without the per-action element / a11y read devtools.enable(trace_granularity='test') # ... one archive per test (implies trace=True) devtools.enable(trace_policy='retain-on-failure') # ... keep only what failed (implies trace=True) ``` `filmstrip` and `a11y` apply to trace mode only, and each defaults to on (`DEVTOOLS_FILMSTRIP` / `DEVTOOLS_A11Y` set the same thing from the environment). `trace` falls back to `DEVTOOLS_TRACE`. `trace_granularity` and `trace_policy` fall back to `DEVTOOLS_TRACE_GRANULARITY` / `DEVTOOLS_TRACE_POLICY`, and passing either one turns trace mode on by itself - see [How many archives, and which ones to keep](#how-many-archives-and-which-ones-to-keep). A value outside the accepted set warns and falls back to the default rather than being discovered later as a missing file. Under pytest the plugin drives all of this from `--devtools` / `--devtools-trace` (or the matching ini option, or `DEVTOOLS_ENABLE=1`), and test boundaries come from pytest's own hooks - there is no `startTest` / `endTest` equivalent to call. ## Examples[​](#examples "Direct link to Examples") * Node.js * Python Working examples live in the repo's top-level `examples/` directory. Build the workspace once (`pnpm install && pnpm build`), then run from the repo root. `pnpm demo:selenium` runs the default (Cucumber) example; the per-runner variants are: | Directory | Runner | Command | | ------------------------------------------------------------------------------------------------------------------- | -------------------- | ------------------------------------------------------------ | | [`examples/selenium-js/mocha/`](https://github.com/webdriverio/devtools/tree/main/examples/selenium-js/mocha) | Mocha | `pnpm --filter @wdio/selenium-devtools example:mocha` | | [`examples/selenium-js/mocha/`](https://github.com/webdriverio/devtools/tree/main/examples/selenium-js/mocha) | Mocha + allure-mocha | `pnpm --filter @wdio/selenium-devtools example:mocha:allure` | | [`examples/selenium-js/jest/`](https://github.com/webdriverio/devtools/tree/main/examples/selenium-js/jest) | Jest | `pnpm --filter @wdio/selenium-devtools example:jest` | | [`examples/selenium-js/cucumber/`](https://github.com/webdriverio/devtools/tree/main/examples/selenium-js/cucumber) | Cucumber | `pnpm demo:selenium` | | [`examples/selenium-js/mobile/`](https://github.com/webdriverio/devtools/tree/main/examples/selenium-js/mobile) | Mocha on Appium | `pnpm demo:selenium:mobile` | The Python examples live in [`examples/selenium-py/`](https://github.com/webdriverio/devtools/tree/main/examples/selenium-py). Install the adapter and build the workspace once (`pnpm install && pnpm build`, so the backend exists), then run from the repo root. The demos run bare `python3`, so the adapter must be installed into that interpreter: `python3 -m venv .venv && source .venv/bin/activate && pip install -e packages/selenium-devtools-py`. | Example | What it shows | Command | | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------- | | `scripts/web_form.py` | The three-line plain-script setup | `pnpm demo:python` | | `scripts/login.py` | A longer script: navigation, form fill, assertions | `pnpm demo:python:login` | | `mobile/android/`, `mobile/ios/` | Appium: the Android Clock app, or iOS Settings with `DEVTOOLS_MOBILE_PLATFORM=ios` (`pip install -r examples/selenium-py/requirements-mobile.txt` first) | `pnpm demo:python:mobile` | | `pytest/` | pytest with a class and a module-level test, plus a `pytest.ini` that commits `devtools = true` and comments every other setting with what it does. It runs live; `DEVTOOLS_MODE=trace` switches it to one archive per failing test through the example's own `conftest.py` (the adapter itself does not read `DEVTOOLS_MODE`) | `pnpm demo:python:pytest` | ## Features[​](#features "Direct link to Features") The Selenium adapter provides the same DevTools UI experience as WebdriverIO, in both languages. Every feature below is captured automatically with no per-feature config — the base `DevTools.configure({})` in Node.js, or `pytest --devtools` in Python. Console and network stream via Selenium's BiDi handlers, with an injected-collector fallback in Node.js. Links go to each feature's full reference. * **[Interactive Test Rerunning & Visualization](/docs/devtools/wdio/interactive-test-rerunning.md)** - Live browser previews, per-command screenshots, and one-click test/suite rerunning * **[Preserve & Rerun (Compare)](/docs/devtools/wdio/preserve-and-rerun.md)** - Snapshot a failing test, rerun it, and diff the two runs side-by-side * **[Multi-Framework Support](/docs/devtools/wdio/multi-framework-support.md)** - Auto-detects Mocha, Jest, Cucumber, or a plain script in Node.js; pytest or a plain script in Python * **[Console Logs](/docs/devtools/wdio/console-logs.md)** - Capture and inspect browser console output * **[Network Logs](/docs/devtools/wdio/network-logs.md)** - Monitor API calls and network activity * **[Metadata](/docs/devtools/wdio/metadata.md)** - Session capabilities, environment, and timing per browser session * **[TestLens](/docs/devtools/wdio/testlens.md)** - Jump from any command to the source line that triggered it * **[Session Screencast](/docs/devtools/wdio/screencast.md)** - Automatic video recording of browser sessions * **Navigation timings** - After every navigation command, load / DOM-ready / response timings, resource counts, cookies and document info are attached to that command row. The row's summary shows the load time in milliseconds to two decimals, such as `246.40 ms`; the full-precision timings stay in the row's performance data * **[Trace Mode](/docs/devtools/wdio/trace-mode.md)** - Headless capture producing a portable `trace.zip` (no UI window), in both languages, with per-test slicing and retention in both (`traceGranularity` / `tracePolicy` in Node.js; `--devtools-trace-granularity` / `--devtools-trace-policy` in Python). Per-test `screenshot` / `video` and inline Allure attachment remain Node.js only; see [Trace mode](#trace-mode) In Node.js, screencast is the one feature with its own options (see [Configuration Options](#configuration-options)): ``` DevTools.configure({ screencast: { enabled: true, quality: 70, maxWidth: 1280, maxHeight: 720 } }) ``` In Python the run's own output also reaches the Console tab: Python `logging` records (selenium's and the adapter's) and the test's `print()` output, which is teed so your terminal still shows it. In Python screencast needs no configuration: Chrome streams frames over CDP, other browsers fall back to one screenshot per command, and encoding the `.webm` needs `ffmpeg` on `PATH`. In trace mode the same frames become the archive's dense filmstrip instead of a `.webm`, so nothing is encoded and `ffmpeg` is not needed. ## How It Works[​](#how-it-works "Direct link to How It Works") * Node.js * Python The plugin patches `selenium-webdriver`'s `Builder`, `WebDriver`, and `WebElement` prototypes at import time: * **`Builder.build()`** - after construction, the driver is registered with the session capturer and the DevTools backend is started in a detached child process. * **Every public `WebDriver` / `WebElement` method** - wrapped with command capture (args + result + screenshot + call source). * **`WebDriver.quit()`** - an awaited cleanup hook flushes screencast encoding, WebSocket buffer, and final metadata before the original quit runs. When BiDi is available (Chrome ≥114), console logs, JavaScript exceptions, and network events stream directly via the Selenium BiDi handlers. Otherwise the plugin falls back to an injected browser-side collector script, so a Safari or Appium session still lists every request, from two sources of the page's own. A `fetch` / `XMLHttpRequest` call goes through the collector's patch and carries its method, headers, status and body. Every other load (the document, scripts, styles, images, fonts) comes from the page's Resource Timing buffer with its timing and size, but no headers or body, and on Safari no status; the Network tab says so on each such row. A `driver.wait()` is one row named after what it waited for, with the commands its condition issued nested under it rather than a row per poll; see [Waits](/docs/devtools/wdio/trace-mode.md#waits). The page-side collector is registered at document start through BiDi (`script.addPreloadScript`), so every page instruments itself before any of its own script runs; without BiDi it falls back to injecting a `<script>` after each navigation. It records the page's **DOM mutation stream** and a per-command element / accessibility snapshot, so a trace carries enough to rebuild the live DOM at each step (per-navigation mapping) — this is what powers the player's DOM time-travel and A11y tab rather than a screenshot-only replay. There are no prototypes to patch, so the Python adapter wraps the one method every command flows through, plus selenium's wait loop: * **`WebDriver.execute()`** - the single chokepoint every command flows through. Element methods delegate to it too (`self._parent.execute`), so `click`, `send_keys` and `text` are captured by the same wrapper without touching the element classes. * **`WebDriverWait.until()` / `until_not()`** - a wait is a client-side loop that `execute` sees only as its polls, so it is patched too: it becomes one row named after what it waited for, with the commands its condition issued nested under it, and a timed-out wait is a failed row carrying the `TimeoutException`. See [Waits](/docs/devtools/wdio/trace-mode.md#waits). * **Session setup** - on the first real command the driver is registered, metadata is sent, and BiDi, the collector and the screencast are armed. * **`quit()`** - intercepted before the session is torn down, so the screencast is encoded and the final frames flushed while the driver still exists. Console, JavaScript exceptions and network stream over selenium's BiDi layer (4.44+), which the adapter enables for you by injecting the `webSocketUrl` capability into the `newSession` request. Where the driver exposes no BiDi at all (Safari, and every session Appium serves) the injected page collector fills the Network tab instead, from two sources of the page's own. A `fetch` / `XMLHttpRequest` call goes through its patch and carries method, headers, status and body. Every other load comes from the document's Resource Timing buffer with its timing and size, but no headers or body, and on Safari no status. The **DOM mutation stream** comes from the same browser-side collector as Node.js, registered at document start through BiDi so a page instruments itself before any of its own script runs. With BiDi disabled (`DEVTOOLS_BIDI=0`) the collector is injected per document with a `<script>` instead. On Chrome the screencast is pushed by the browser over a CDP websocket of its own — separate from the session's command channel, which is what makes a real frame stream safe when a Selenium session is not thread-safe. ## Mobile (Appium)[​](#mobile-appium "Direct link to Mobile (Appium)") Appium sessions are captured in live and trace mode, in both languages. A mobile-browser session is captured like a desktop one; a native app gets commands, screenshots and element data from the platform's XML tree, with no DOM. This adapter decides from the startup capabilities, so a hybrid app's webview half is captured as if it were still native (only the WebdriverIO service follows context switches). Try it with `pnpm demo:selenium:mobile` (Node.js) or `pnpm demo:python:mobile` (Python), run from the root of a built checkout of the devtools repo (setup steps in [Running an example](/docs/devtools/mobile.md#running-an-example)). `DEVTOOLS_MOBILE_PLATFORM=ios` runs the iOS spec, and `DEVTOOLS_MOBILE=web` drives the device's own browser. Prerequisites are in [`examples/MOBILE.md`](https://github.com/webdriverio/devtools/blob/main/examples/MOBILE.md); see the [Mobile Testing page](/docs/devtools/mobile.md) for the full mobile reference. A native app's network is captured when the session sets `appium:intercept: true` and Appium runs the appium-interceptor plugin; see [Native app network](/docs/devtools/mobile.md#native-app-network). ## Limitations[​](#limitations "Direct link to Limitations") * Node.js * Python | Limitation | Detail | | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Cucumber leaf-step rerun | Cucumber's `--name` filter targets scenarios, not individual Gherkin steps. The dashboard's per-step rerun is disabled under Cucumber. | | Headless mode caveat | `headless: true` injects `--headless=old`; `--headless=new` produces all-black CDP frames in the screencast. | | Initial viewport | The dashboard's snapshot iframe falls back to 1280×800 until the first navigation completes and the browser-side collector reports the real viewport. | | Parallel workers | Jest/Vitest worker processes each load the plugin and report as a separate run, so the dashboard keeps only the latest worker's state. Run serially (`--runInBand`) for a single dashboard run. | | Safari in live mode | Safari delivers synthesized input only to its frontmost window and still reports success, so input issued while another window is in front reaches nothing. On Safari the plugin opens the dashboard behind the browser and brings the session's own window forward before each element click, key input, clear or submit. Trace mode opens no window and is not affected. | | Limitation | Detail | | ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | No per-test screenshot, video or Allure attach | Per-test **trace archives** are supported (`--devtools-trace-granularity test`), but the Node.js adapter's per-test `screenshot` and `video` options and its inline `allure-js-commons` attachment have no Python equivalent - the archives are the artifacts. | | Retry-aware retention degrades | `retain-on-first-failure`, `on-first-retry`, `on-all-retries` and `retain-on-failure-and-retries` are accepted but behave exactly like `retain-on-failure`: nothing on the wire carries an attempt number, so a retried test overwrites its own earlier outcome. The backend logs the degradation. | | Node is required in every mode | The backend is a Node application - it serves the page collector, carries the event stream, and builds the trace archive - so Node.js 22.23.4+, 24.22.1+ or 26.12.1+ must be present even in trace mode, where no window opens. The adapter finds or launches it for you. | | Browser options are yours | There is no `headless` option; configure Chrome through selenium's own `Options` object as you normally would. | | Live-mode video needs ffmpeg | Without `ffmpeg` on `PATH` the `.webm` encode is skipped with a warning rather than an error. Trace mode encodes none - its frames go into the filmstrip - so it never needs ffmpeg. | --- Source: https://webdriver.io/docs/devtools/nightwatch.md # Nightwatch DevTools Nightwatch adapter for [WebdriverIO DevTools](https://github.com/webdriverio/devtools) - brings the same visual debugging UI to your Nightwatch test suite with zero test code changes. ## Installation[​](#installation "Direct link to Installation") ``` npm install @wdio/nightwatch-devtools ``` Requires Node.js 22.23.4+, 24.22.1+ or 26.12.1+ and Nightwatch 3 or later. For Cucumber, `@cucumber/cucumber` must be installed in your project; the adapter uses your copy rather than bundling one. ## Setup[​](#setup "Direct link to Setup") ### Standard Nightwatch (mocha-style)[​](#standard-nightwatch-mocha-style "Direct link to Standard Nightwatch (mocha-style)") ``` // nightwatch.conf.cjs const nightwatchDevtools = require('@wdio/nightwatch-devtools').default module.exports = { src_folders: ['tests'], test_settings: { default: { desiredCapabilities: { browserName: 'chrome', // Required for network request capture 'goog:loggingPrefs': { performance: 'ALL' } }, globals: nightwatchDevtools({ port: 3000 }) } } } ``` Run your tests as normal - the DevTools UI opens automatically in a new browser window: ``` nightwatch ``` > No changes to your test files are needed. In live mode the run stays open after your tests finish so you can review the results. Close the DevTools window to end it, or press Ctrl+C to exit and leave the window open. ### Cucumber / BDD[​](#cucumber--bdd "Direct link to Cucumber / BDD") Import `cucumberHooksPath` alongside the main export and pass it to the Cucumber `require` option. This registers `Before` / `After` scenario hooks and `BeforeStep` / `AfterStep` step hooks that mirror the WebdriverIO service's `beforeScenario` / `afterScenario` behaviour. A pre-quit `After` hook flushes each scenario's trace while its browser session is still live. ``` // nightwatch.conf.cjs const nightwatchDevtools = require('@wdio/nightwatch-devtools').default const { cucumberHooksPath } = require('@wdio/nightwatch-devtools') module.exports = { src_folders: ['features/step_definitions'], test_runner: { type: 'cucumber', options: { feature_path: 'features', require: [cucumberHooksPath] // <-- register DevTools Cucumber hooks } }, test_settings: { default: { desiredCapabilities: { browserName: 'chrome', 'goog:loggingPrefs': { performance: 'ALL' } }, globals: nightwatchDevtools({ port: 3000 }) } } } ``` ## Configuration Options[​](#configuration-options "Direct link to Configuration Options") | Option | Type | Default | Description | | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `port` | `number` | `3000` | Port for the DevTools backend server. Auto-incremented if already in use. | | `hostname` | `string` | `'localhost'` | Hostname the backend server binds to. | | `screencast` | `ScreencastOptions` | `{ enabled: false }` | Per-session `.webm` video recording, live mode only. In trace mode use `filmstrip` / `video`. See [Screencast](#screencast) below. | | `bidi` | `boolean` | `false` | Opt into WebDriver BiDi capture for browser console + JS exceptions + network. Requires `webSocketUrl: true` in your capabilities and a BiDi-capable chromedriver. When attached, the per-command Chrome perf-log network path is gated off so requests don't duplicate. | | `mode` | `'live' \| 'trace'` | `'live'` | `live` opens the DevTools UI; `trace` skips it and writes a portable artifact instead. See [Trace Mode](/docs/devtools/wdio/trace-mode.md). | | `traceFormat` | `'zip' \| 'ndjson-directory'` | `'zip'` | Trace artifact layout. Only applies when `mode: 'trace'`. | | `traceGranularity` | `'session' \| 'spec' \| 'test'` | `'session'` | One trace per session / spec file / test. `'test'` writes each to `test-results/<spec>-<title>-<browser>[-retryN]/trace.zip`. Only applies when `mode: 'trace'`. See [Trace Mode](/docs/devtools/wdio/trace-mode.md#trace-granularity--tracegranularity). **Caveat:** the BDD `describe/it` interface collapses to a single session-scoped slice (see [Per-test slicing](#per-test-slicing--the-bdd-describeit-caveat)). | | `tracePolicy` | `'on' \| 'retain-on-failure' \| 'retain-on-first-failure' \| 'on-first-retry' \| 'on-all-retries' \| 'retain-on-failure-and-retries'` | `'on'` | Which traces to keep. Pairs with `traceGranularity: 'test'`. Only applies when `mode: 'trace'`; setting it outside trace mode logs a warning. **Caveat:** only `'retain-on-failure'` is reliable on Nightwatch. The other retry-aware policies degrade to it, because `--retries` re-runs a testcase internally without re-firing the plugin's per-test hooks. | | `filmstrip` | `boolean` | `true` | Record a dense, continuous screencast filmstrip into the trace for scrubbable playback in the trace player — not just one frame per action. Runs the screencast recorder (polling mode on Nightwatch) for the session. Only applies when `mode: 'trace'`. | | `screenshot` | `'off' \| 'on' \| 'only-on-failure'` | `'off'` | Per-test screenshot. Trace mode + `traceGranularity: 'test'` only. **Produce-only** — the PNG is written to the trace output dir (and the manifest when `emitArtifactsManifest: true`); not attached inline to Allure (see note below). | | `video` | `'off' \| TraceRetentionPolicy` | `'off'` | Per-test video slice, retained per the given policy (e.g. `'retain-on-failure'`). Trace mode + `traceGranularity: 'test'` only. A non-`off` value starts the screencast recorder itself — you do **not** also need `filmstrip` or `screencast.enabled`. **Produce-only** — the `.webm` is written to the trace output dir (and the manifest when `emitArtifactsManifest: true`); not attached inline to Allure. | | `emitArtifactsManifest` | `boolean` | `false` | Write the `devtools-artifacts-<sessionId>.json` manifest (the generic index reporters/CI consume to discover produced artifacts) next to the trace. **Opt-in for Nightwatch** — it has no live Allure signal to auto-detect against, so unlike WDIO/Selenium it never auto-enables. Only applies when `mode: 'trace'`. | | `captureAssertions` | `boolean` | `true` | Capture assertions as trace action rows — `node:assert` plus native `browser.assert`/`browser.verify`, including negated `.not.*` matchers. Set `false` to opt out. | > **Inline Allure attachment is not supported for Nightwatch.** Its official `nightwatch-allure` reporter is post-hoc (no live attach API), and `allure-js-commons`' `attachment()` no-ops in a Nightwatch run. So `screenshot` / `video` artifacts are *produced* (files, plus the artifacts manifest when `emitArtifactsManifest: true`) in the trace output dir but not attached to an Allure test. Per-test slicing — and therefore these artifacts — is meaningful for the Cucumber and exports-object interfaces; the BDD `describe/it` interface collapses to session granularity, so the per-test gate no-ops there. ``` globals: nightwatchDevtools({ port: 3000, hostname: 'localhost', screencast: { enabled: true }, bidi: true }) ``` ## Screencast[​](#screencast "Direct link to Screencast") Record a continuous `.webm` video of the browser session. Each WebDriver session gets its own recording: a mid-run `browser.end()`, or the per-scenario browser quit in Cucumber, finalizes the current video and starts a new one for the next session. The last recording is finalized in Nightwatch's `after()` hook, and every recording can be picked from the Screencast tab's dropdown. **Polling mode only.** Nightwatch doesn't expose a stable CDP escape hatch the way WebdriverIO (`browser.getPuppeteer()`) and Selenium (`driver.createCDPConnection`) do, so the screencast captures frames by requesting a WebDriver screenshot at a fixed interval. The request goes straight over the WebDriver HTTP transport, bypassing Nightwatch's command queue, so it never waits behind your test's commands. Works on every browser Nightwatch supports. ``` globals: nightwatchDevtools({ port: 3000, screencast: { enabled: true, pollIntervalMs: 200 } }) ``` | Option | Type | Default | Notes | | ------------------------------------ | ----------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `enabled` | `boolean` | `false` | Master switch. | | `pollIntervalMs` | `number` | `200` | Screenshot interval (ms). Lower = smoother video, more WebDriver round-trips. 200 ms ≈ 5 fps. | | `captureFormat` | `'jpeg' \| 'png'` | `'jpeg'` | Per-frame pixel format handed to the ffmpeg encoder before the final `.webm` mux. In polling mode the source screenshots are always captured as PNG, so this does **not** change the capture - only the format the encoder receives per frame. | | `maxBufferFrames` | `number` | `2000` | Cap on frames held in memory. Past it the buffer is thinned in place, keeping the first and last frames. | | `maxWidth` / `maxHeight` / `quality` | - | - | CDP-only options, ignored in polling mode. Listed for shape compatibility with the WDIO/Selenium adapters. | **Prerequisites:** `fluent-ffmpeg` (already a runtime dep of the package) plus the `ffmpeg` binary on PATH. macOS: `brew install ffmpeg`. Linux: `apt install ffmpeg`. Without ffmpeg the recorder still runs but the encode step logs a warning and skips writing the file. **Output:** `nightwatch-video-<sessionId>.webm` is written to a `test-results/` folder next to the test file that just ran, falling back to the `nightwatch.conf.*` directory, then `process.cwd()`. Directories under `node_modules/` are skipped, and if the chosen directory isn't writable the file goes to the OS temp directory. The full path appears in the Nightwatch log line `📹 Screencast video: <path>` and the video is also streamed to the dashboard's Screencast tab. For the full screencast feature reference (browser support, output paths across all three adapters), see the [Screencast page](/docs/devtools/wdio/screencast.md). ## BiDi capture (opt-in)[​](#bidi-capture-opt-in "Direct link to BiDi capture (opt-in)") Enable WebDriver BiDi capture for browser console messages, JS exceptions, and network requests. Equivalent to the path selenium-devtools uses - both adapters share the same attach logic in `@wdio/devtools-core`. ``` globals: nightwatchDevtools({ port: 3000, bidi: true }) ``` You also need `webSocketUrl: true` in your capabilities so chromedriver actually exposes the BiDi channel: ``` desiredCapabilities: { browserName: 'chrome', webSocketUrl: true, // ← enables BiDi 'goog:chromeOptions': { /* ... */ } } ``` When BiDi is attached, the per-command Chrome performance-log network capture path is gated off so requests don't appear twice in the dashboard. If `webSocketUrl` is missing or the chromedriver version doesn't expose BiDi, the attach logs a warning and the perf-log fallback continues to work. The injected collector lists every request as well, from two sources of the page's own: a `fetch` / `XMLHttpRequest` call goes through its patch and carries method, headers, status and body, and every other load comes from the page's Resource Timing buffer with its timing and size. On Chrome the performance log then upgrades those Resource Timing rows in place with headers and status; on Safari, or any session Appium serves, they stay as the page saw them, without headers or bodies, and on Safari without a status. See [Network Logs](/docs/devtools/wdio/network-logs.md#without-webdriver-bidi). **Set `webSocketUrl: true` even without `bidi: true`.** With it, the adapter registers its page collector at document start on every page, so DOM time-travel stays accurate across navigations. Without it, the adapter falls back to injecting the collector after each navigation, which can miss the first moments of a new page. ## Direct WebDriver reads and remote grids[​](#direct-webdriver-reads-and-remote-grids "Direct link to Direct WebDriver reads and remote grids") Some reads the plugin makes go straight to the driver over the WebDriver HTTP transport instead of through Nightwatch's command queue: the page collector's probes and drains, the per-action snapshot probes and screenshots, the screencast's screenshots, and, on a session without BiDi, Chrome's performance log. A command issued through the queue while a test command is running would become part of that command and let its `await` return before it finished, so these reads never join the queue and never cut a test command short. They use the connection Nightwatch itself is configured with: https when `webdriver.ssl` is set, or when it is unset and the port is 443, and basic authentication from `webdriver.username` and `webdriver.access_key`. A remote grid on https or behind credentials therefore needs no extra configuration for the plugin. ## Trace mode[​](#trace-mode "Direct link to Trace mode") Headless capture path — no DevTools UI window opens. At session end the adapter writes a portable `trace-<sessionId>.zip` (or directory) into a `test-results/` folder (next to the resolved test / config directory), with the same shape as the WebdriverIO trace artifact. ``` globals: nightwatchDevtools({ mode: 'trace', traceFormat: 'ndjson-directory' // optional; default 'zip' }) ``` ### Granularity and Cucumber[​](#granularity-and-cucumber "Direct link to Granularity and Cucumber") `traceGranularity` chooses what one artifact covers — `'session'` (default), `'spec'`, or `'test'`. Nightwatch quits the browser after every Cucumber scenario. A `'session'` trace spans that: one zip for the whole run, with every scenario nested under its feature. `'test'` writes one zip per scenario into its own folder, which is the recommendation for Cucumber — smaller artifacts, and the granularity that `tracePolicy` retention keys on. ``` globals: nightwatchDevtools({ mode: 'trace', traceGranularity: 'test' // one trace per Cucumber scenario }) ``` On the BDD `describe/it` interface, `'test'` collapses to a single session-scoped slice: Nightwatch runs each `it()` internally and fires the plugin's per-test hook only once per module. The action tree still shows each `it` as its own group. The backend port-bind and UI window are skipped in trace mode, and `screencast.enabled` is ignored (a warning is logged when nothing else needs the recorder). Trace mode records the dense `filmstrip` by default instead, and the screencast tuning fields (`pollIntervalMs`, `captureFormat`, `maxBufferFrames`) still apply to that recorder. For the full feature reference (artifact contents, viewer, mobile testing, when to pick `zip` vs `ndjson-directory`), see the [Trace Mode page](/docs/devtools/wdio/trace-mode.md). Nightwatch shares the same trace pipeline as the WebdriverIO and Selenium adapters, so the artifact shape is identical no matter which adapter produced it. A Nightwatch trace carries the full per-action capture — a screenshot, the depth-indented accessibility-tree snapshot, the interactable-element list, and the Markdown transcript — so it opens in the `show-trace` player with DOM/snapshot time-travel, the **A11y**, **Transcript** and **Errors** tabs (failures with jump-to-source), the pick-locator element overlay, and (for Cucumber) **Feature → Scenario** nesting. Steps are tracked in the live dashboard but are not yet nested as their own groups in the trace. Copied locators prefer plain CSS, which Nightwatch reads by default; only when no unique CSS selector exists does the player hand you XPath, captioned with `useXpath()` / `locateStrategy: 'xpath'`. Open a trace with the `show-trace` bin, shipped with `@wdio/nightwatch-devtools` (no extra dependency): ``` npx show-trace test-results/trace-<sessionId>.zip # in a project that installs the adapter pnpm show-trace test-results/trace-<sessionId>.zip # from the devtools monorepo ``` See the [Trace Player](/docs/devtools/trace-player.md) page for the full walkthrough and keyboard shortcuts. ### Per-test slicing & the BDD `describe/it` caveat[​](#per-test-slicing--the-bdd-describeit-caveat "Direct link to per-test-slicing--the-bdd-describeit-caveat") The per-test options — `traceGranularity: 'test'`, and the `tracePolicy`, `screenshot`, and `video` options that pair with it — need a per-test hook to cut each test's slice. The **exports-object (mocha-style)** interface and **Cucumber** (per-scenario hooks) expose one, so they get real per-test slicing. The **BDD `describe/it`** interface is the exception: Nightwatch runs each `it()` internally and fires the plugin's per-test hook only once per module, so `traceGranularity: 'test'` collapses to a single **session-scoped** slice keyed to the first test. The artifacts manifest still lists every testcase with its correct state; only the per-test slice/artifact keying collapses. Session- and spec-granularity traces are unaffected. ## Examples[​](#examples "Direct link to Examples") Working examples live in the repo's top-level `examples/` directory. Build the workspace once (`pnpm install && pnpm build`), then run from the repo root: | Directory | Runner | Command | | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | | [`examples/nightwatch/`](https://github.com/webdriverio/devtools/tree/main/examples/nightwatch) | Nightwatch BDD `describe/it` (trace mode by default; `DEVTOOLS_MODE=live` for the UI) | `pnpm demo:nightwatch` (`pnpm demo:nightwatch:retry` adds `--retries 1`) | | [`examples/nightwatch/cucumber/`](https://github.com/webdriverio/devtools/tree/main/examples/nightwatch/cucumber) | Nightwatch + Cucumber | `pnpm --filter @wdio/nightwatch-devtools example:cucumber` | | [`examples/nightwatch/`](https://github.com/webdriverio/devtools/tree/main/examples/nightwatch) (`nightwatch.mobile.conf.cjs`) | Appium (Android Clock app; iOS Settings with `DEVTOOLS_MOBILE_PLATFORM=ios`) | `pnpm demo:nightwatch:mobile` | ## Mobile (Appium)[​](#mobile-appium "Direct link to Mobile (Appium)") Appium sessions are captured in live and trace mode. Declare Appium under `selenium` with `use_appium: true`, `start_process: false` and `default_path_prefix: ''`. For a native app set `browserName: null`; otherwise Nightwatch fills in Firefox and the adapter treats the session as having a web page. Leave `bidi` off, since Appium serves no BiDi. A native app's network is captured when `desiredCapabilities` sets `'appium:intercept': true` and Appium runs the appium-interceptor plugin; see [Native app network](/docs/devtools/mobile.md#native-app-network). ``` // nightwatch.mobile.conf.cjs const nightwatchDevtools = require('@wdio/nightwatch-devtools').default module.exports = { selenium: { start_process: false, use_appium: true, host: '127.0.0.1', port: 4723, default_path_prefix: '' }, test_settings: { default: { desiredCapabilities: { browserName: null, platformName: 'Android', 'appium:automationName': 'UiAutomator2' }, globals: nightwatchDevtools({ mode: 'trace', bidi: false }) } } } ``` Native sessions record commands, screenshots and element data from the platform's XML tree, with no DOM. A hybrid app's webview is captured as if it were still native. Try it with `pnpm demo:nightwatch:mobile`, run from the root of a built checkout of the devtools repo (setup steps in [Running an example](/docs/devtools/mobile.md#running-an-example)). See the [Mobile Testing page](/docs/devtools/mobile.md) for the full mobile reference. ## Features[​](#features "Direct link to Features") The Nightwatch adapter provides the same DevTools UI experience as WebdriverIO. Every feature below is captured automatically with the base `globals: nightwatchDevtools({ port: 3000 })` setup — no per-feature config (network logs additionally need `'goog:loggingPrefs': { performance: 'ALL' }`, shown in [Setup](#setup)). Links go to each feature's full reference. * **[Interactive Test Rerunning & Visualization](/docs/devtools/wdio/interactive-test-rerunning.md)** - Live browser previews, per-command screenshots, and one-click test/suite rerunning * **[Preserve & Rerun (Compare)](/docs/devtools/wdio/preserve-and-rerun.md)** - Snapshot a failing test, rerun it, and diff the two runs side-by-side. Nightwatch reruns relaunch your config with `DEVTOOLS_RERUN_LABEL` set and filter down to that test; they need a discoverable `nightwatch.conf.*`, without which the plugin warns and rerun is unavailable * **[Multi-Framework Support](/docs/devtools/wdio/multi-framework-support.md)** - Standard (mocha-style) and Cucumber/BDD runners * **[Console Logs](/docs/devtools/wdio/console-logs.md)** - Capture and inspect browser console output (real-time with `bidi: true`) * **[Network Logs](/docs/devtools/wdio/network-logs.md)** - Monitor API calls and network activity * **[Metadata](/docs/devtools/wdio/metadata.md)** - Session capabilities, environment, and timing per browser session * **[TestLens](/docs/devtools/wdio/testlens.md)** - Jump from any command to the source line that triggered it * **[Session Screencast](/docs/devtools/wdio/screencast.md)** - Continuous `.webm` recording of the browser session * **[Trace Mode](/docs/devtools/wdio/trace-mode.md)** - Headless capture producing a portable `trace.zip` (no UI window) Screencast is the one feature with its own options (full list under [Screencast](#screencast)): ``` globals: nightwatchDevtools({ port: 3000, screencast: { enabled: true, pollIntervalMs: 200 } }) ``` ## Limitations[​](#limitations "Direct link to Limitations") Nightwatch does not provide the same depth of framework hooks as WebdriverIO, so there are a few differences from the WDIO DevTools service: | Limitation | Detail | | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | No native command hooks | Nightwatch has no `beforeCommand` / `afterCommand` hook. Commands are intercepted via a browser proxy wrapper instead. | | Limited test context | `browser.currentTest` provides less metadata than the WDIO runner context; test names and file paths require additional heuristics. | | Flat suite nesting | Nightwatch does not natively support multiply-nested `describe` blocks; the plugin reports a maximum of two levels. | | Delayed result availability | Test results are only finalised in `afterEach`, not available mid-test. | | Screencast in polling mode only | Unlike WDIO (CDP push via `browser.getPuppeteer()`) and Selenium (CDP push via `driver.createCDPConnection`), Nightwatch lacks a stable CDP escape hatch, so frames are captured by polling the WebDriver screenshot endpoint. Works on every browser Nightwatch supports; small per-frame cost proportional to the polling interval. | | Per-test trace slicing (BDD `describe/it`) | The BDD interface fires the plugin's per-test hook once per module, so `traceGranularity: 'test'` collapses to one session-scoped slice. The exports-object (mocha-style) and Cucumber interfaces get real per-test slicing. See [Per-test slicing](#per-test-slicing--the-bdd-describeit-caveat). | | Retry-aware retention | Only `tracePolicy: 'retain-on-failure'` is reliable; the other retry-aware policies degrade to it. | | Element waits show no polls | A `waitForElement*` wait is one row with nothing nested under it: Nightwatch polls for the element through its own transport, which the plugin does not see. A `waitUntil` row nests the commands its condition issued. See [Waits](/docs/devtools/wdio/trace-mode.md#waits). | | A wait that never ran is a failed row | Nightwatch queues every command up front, so a wait queued behind a failing `assert` never runs. Its row is closed at the end of the test as failed, "did not run", rather than left looking like it passed. | | Produce-only trace artifacts | Per-test `screenshot` / `video` files are written to the trace output dir (and the manifest when `emitArtifactsManifest: true`) but not attached inline to Allure — Nightwatch has no live Allure attach API. | Overall feature parity with the WebdriverIO DevTools service is approximately **80-90%**.