Skip to main content

WebDriver BiDi protocol support

· 4 min read

Support for the WebDriver BiDi protocol (the future unified standard for browser automation) has been added in testplane@8.27.0.

WebDriver BiDi (Bidirectional) is a new cross-browser automation protocol that combines the best features of existing protocols: W3C WebDriver and Chrome DevTools Protocol (CDP) (you can read more about them in our article). Essentially, the new protocol extends the existing W3C WebDriver protocol and adds new cross-browser commands that replace the CDP protocol (which is not cross-browser compatible). Old webdriver commands still work via HTTP, while new commands provide bidirectional communication between the client and the browser via a WebSocket connection.

The new protocol is currently supported by the following browsers: Chrome, Firefox, Edge. Safari support is not available yet. You can follow the supported browsers on this page.

A list of BiDi protocol commands is available on this page.

How to use?

warning

BiDi protocol support in Testplane is available in browsers starting from version: chrome@128 and firefox@129.

To use the BiDi protocol, you need to:

  • install testplane@8.27.0 or older;
  • specify the capability webSocketUrl: true in the desiredCapabilities field for the desired browser (it will be set by default in the next major version);
  • run the tests.

What can be done with the new protocol?

Tracking and intercepting network requests/responses

  1. You can mock a request to testplane.io and return your own response:
it("should mock testplane.io", async ({ browser }) => {
await browser.networkAddIntercept({ phases: ["beforeRequestSent"] });

browser.on("network.beforeRequestSent", networkRequest => {
browser.networkProvideResponse({
request: networkRequest.request.request,
body: {
type: "string",
value: "hello world",
},
});
});

await browser.url("https://testplane.io");
});
  1. We will intercept all requests to the testplane.io resource and display a list of all loaded URLs:
it("should log all loaded urls", async ({ browser }) => {
browser.on("network.responseCompleted", networkResponse =>
console.log("got response from url:", networkResponse.response.url),
);

await browser.url("https://testplane.io");
});

Displaying logs in the browser

it("should show browser console logs", async ({ browser }) => {
browser.on("log.entryAdded", entryAdded => console.log(JSON.stringify(entryAdded, null, 4)));

await browser.execute(() => console.log("Hello Bidi"));
});

Taking a screenshot of the entire page

import * as fs from "node:fs";

it("should screen full page", async ({ browser }) => {
await browser.url("https://www.npmjs.com/");

const tree = await browser.browsingContextGetTree({});
const file = await browser.browsingContextCaptureScreenshot({
context: tree.contexts[0].context,
origin: "document",
});

fs.writeFileSync("screenshot.png", Buffer.from(file.data, "base64"));
});

Conclusion

While the BiDi protocol remains in the Editor's Draft stage, its potential as the future standard is already clear. Major browsers like Firefox have taken decisive steps toward adoption, announcing the deprecation of CDP protocol support starting in version 129.

By embracing BiDi protocol support, we're empowering our users with:

  • enhanced test automation capabilities beyond what WebDriver could offer;
  • freedom from Puppeteer dependencies - eliminating the instability issues we've consistently observed in CDP-based implementations;
  • Future-proof testing infrastructure by aligning with emerging industry standards

We encourage you to upgrade to the latest Testplane version and share your experience. Should you encounter any challenges, our team is ready to assist through GitHub issue - just create a ticket and we'll help resolve it promptly!