Testplane Commands
Overview
This reference covers Testplane v9 and its @testplane/webdriverio dependency. Check the protocol on the command page: WebDriver BiDi and Classic can expose different methods, even in the same browser. For older versions, use the documentation archive and WebdriverIO v8.
Testplane does not provide the WDIO runner's implicit global browser, $ and $$. Get browser from the test argument, or use this.browser in a regular function. An arrow function does not receive the test's this context. Find elements with browser.$ and browser.$$.
Example
Both tests open / relative to baseUrl. The test page must contain an h1 with the text Command examples.
const assert = require("node:assert/strict");
it("commands: use the browser fixture", async ({ browser }) => {
await browser.url("/");
assert.equal(await browser.$("h1").getText(), "Command examples");
});
it("commands: use this.browser with a regular function", async function () {
await this.browser.url("/");
assert.equal(await this.browser.$("h1").getText(), "Command examples");
});
Run the examples
Save the JavaScript block in a Testplane test file. For examples that open relative URLs, set baseUrl to a local HTTP site. Serve an HTML page at / and provide the routes and responses listed on the command page. Run the test with npx testplane. The downloadFile example also needs a Selenium Grid with managed downloads.
Choose a command
| Task | Commands |
|---|---|
| Page setup and emulation | addInitScript, emulate, restore, setViewport |
| Custom selectors | addLocatorStrategy, browser.custom$, browser.custom$$, element.custom$, element.custom$$ |
| Frames and downloads | switchFrame, downloadFile |
| Resource throttling | throttleCPU, throttleNetwork |
| Element operations | execute, executeAsync, getElement, isStable, waitForStable |
| Network interception | mock, waitForResponse, request, requestOnce, redirect, redirectOnce, reset |
| Testplane extensions | extendOptions, browser.unstable_captureDomSnapshot, element.unstable_captureDomSnapshot, unstable_getCdp |
Reference scope
Low-level WebDriver, BiDi and Appium commands are not duplicated here: see WebdriverIO protocols. Methods of InitScript and clock objects are documented with addInitScript and emulate, not as separate browser commands. When using external recipes, account for version differences and how Testplane provides browser.