CDP over WebDriver BiDi
Selenium.WebDriver.BiDi.Cdp is a .NET library that provides strongly-typed access to the Chrome DevTools Protocol (CDP) over the WebDriver BiDi transport, extending Selenium WebDriver.
Features
- 50+ CDP domains — Page, Network, DOM, Runtime, Debugger, Console, and more.
- Fully async —
async/awaitwithCancellationTokensupport throughout. - Strongly typed — auto-generated records for all commands, parameters, and results.
- AOT and trimming compatible — supports Native AOT compilation and IL trimming on .NET 8+.
- Source-generated JSON — uses
System.Text.Jsonsource generators for fast, allocation-free serialization.
Installation
dotnet add package Selenium.WebDriver.BiDi.Cdp
Quick start
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using Selenium.WebDriver.BiDi.Cdp;
await using var driver = new ChromeDriver(new ChromeOptions { UseWebSocketUrl = true });
await using var bidi = await driver.AsBiDiAsync();
var tab = (await bidi.BrowsingContext.GetTreeAsync()).Contexts[0].Context;
// Your entry point
var cdp = await tab.AsCdpAsync();
// Capture a screenshot
var result = await cdp.Page.CaptureScreenshotAsync();
Console.WriteLine($"Screenshot data length: {result.Data.Length}");
Learn more
- Introduction — what the library is and why it exists.
- Getting started — install, connect, and run your first CDP command.
- API reference — full API documentation for all CDP domains.