BiDi and CDP Overview

Two-Way Communication

Classic WebDriver is one-way: your test sends a command and waits for a reply. Modern apps also need the browser to tell the test about events: a console error, a network request, a JavaScript exception. Selenium 4 offers two ways.

Chrome DevTools Protocol (CDP)WebDriver BiDi
WhatChrome's internal debugging protocolnew W3C standard bidirectional protocol
BrowsersChrome, Edge (Chromium)Chrome, Edge, Firefox (growing)
Stabilitytied to the Chrome version (devtools.v130 packages)stable, cross-browser API
Selenium's directionbeing replacedthe future; use when available

Enabling BiDi

ChromeOptions options = new ChromeOptions();
options.setCapability("webSocketUrl", true);      // turns on WebDriver BiDi
WebDriver driver = new ChromeDriver(options);

Note: High-level helpers such as NetworkInterceptor, HasAuthentication and LogInspector hide the protocol details. Prefer them to raw CDP commands, which break when Chrome updates.

Basic Authentication

// QA environments often sit behind HTTP basic auth
((HasAuthentication) driver).register(UsernameAndPassword.of("qa", System.getenv("QA_BASIC_PWD")));
driver.get("https://qa.shopease.example.com");

Without this, the browser shows a native login popup that Selenium cannot type into.