Skip to main content

unstable_getCdp

Overview​

Get Testplane’s existing Chrome DevTools Protocol connection for advanced diagnostics. This is Testplane’s CDP object, not a Puppeteer browser or a Puppeteer CDPSession.

Usage​

browser.unstable_getCdp()

Parameters​

This command has no parameters.

Result​

Promise<CDP | null>. Returns null for a non-Chromium session or when Testplane could not establish its CDP connection.

Limitations​

Check for null before use. cdp.request(method, params?, cdpSessionId?) sends a raw CDP request; page-targeted commands may need an attached target session ID. Domain helpers include target, runtime, network, page, dom, css, fetch, debugger and profiler. Their contracts are also unstable. Do not call cdp.close(): Testplane owns and uses this shared connection. Avoid changing domains used by the runner unless you understand the interaction.

warning

This is an unstable Testplane API. Its signature, behavior and result format may change between versions.

Example​

Run this test in a Chromium browser with an available CDP connection. It reads browser version metadata without changing the page or closing the shared connection.

const assert = require("node:assert/strict");

it("unstable_getCdp: query the connected Chromium browser", async ({ browser }) => {
const cdp = await browser.unstable_getCdp();
assert.ok(cdp, "This test requires a Chromium session with a CDP connection");
const version = await cdp.request("Browser.getVersion");
assert.match(version.product, /Chrome/);
assert.equal(typeof version.protocolVersion, "string");
// Testplane owns this connection: do not call cdp.close().
});

See also​