Skip to main content

BiDi Testing with Selenium WebDriver on LambdaTest

Selenium WebDriver BiDi is a W3C standard protocol used to establish communication between a test script and a remote WebDriver server. It introduces bi-directional communication, which means both the script and the browser can send requests and responses, leading to a more dynamic and reactive testing experience.

Why to use WebDriver BiDi Protocol?

There are several compelling reasons to consider using BiDi testing with Selenium WebDriver on LambdaTest:

  • Enhanced Test Maintainability : Traditional WebDriver relies on a request-response model, where the test script dictates every action. BiDi introduces a standardized protocol, making your tests less vulnerable to breaking due to browser version changes. This reduces maintenance overhead as your tests adapt more gracefully to browser updates.

  • Boosted Automation Capabilities : BiDi's key strength lies in its bi-directional communication and event-driven architecture. This allows for a more dynamic and responsive testing experience compared to the traditional approach. Your tests can react to events happening within the browser itself, leading to more robust and adaptable automation.

  • Seamless Cross-Browser Support : BiDi is a W3C standard, meaning it strives for consistent implementation across different browsers. This eliminates the need to write and maintain separate test scripts for each browser you want to support. With LambdaTest's vast browser grid, you can leverage BiDi for wider test coverage with a single, unified test suite.

  • Fine-Grained Control over Browser Interactions : BiDi offers access to lower-level browser functionalities that weren't readily available with traditional WebDriver. You can now interact with browser features like console logs and network traffic, providing finer control over the testing process. This can be particularly useful for debugging complex test scenarios or monitoring browser behavior in more detail.

  • Future-Proofing Your Test Suite : BiDi represents the future of web browser automation. By adopting BiDi early on, you're future-proofing your test suite and ensuring compatibility with upcoming browser advancements that leverage this powerful protocol.

Steps to run tests

Following are the steps to run tests on LambdaTest using WebdriverIO with BiDi Protocol:


Step 1: Setup the project

You can use your own project to configure and test it. For demo purposes, we are using the sample repository.

Sample repo

Download or Clone the code sample for the TestNG from the LambdaTest GitHub repository to run the tests on the HyperExecute.

Image View on GitHub

Install all the necessary dependencies of the project by running the following command:

npm install

Step 2: Set up your LambdaTest credentials

  • Create a .env file in the root folder of your project.
  • Add your LambdaTest Username and Access Key in place of <YOUR_USERNAME> and <YOUR_ACCESS_KEY>

Step 3: Trigger the tests

  • Pass the webSocketUrl as true in the wdio.lambdatest.conf.js file to enable BiDi support.

    webSocketUrl: true
  • Run the following command in your terminal to trigger the tests on LambdaTest platform using the specified configuration.

    npm run wdio

Test across 3000+ combinations of browsers, real devices & OS.

Book Demo

Help and Support

Related Articles