File: class-cdpsession.md | Updated: 11/18/2025
On this page
The CDPSession instances are used to talk raw Chrome Devtools Protocol:
session.send method.session.on method.Useful links:
Documentation on DevTools Protocol can be found here: DevTools Protocol Viewer .
Getting Started with DevTools Protocol: https://github.com/aslushnikov/getting-started-with-cdp/blob/master/README.md
var client = await Page.Context.NewCDPSessionAsync(Page);await client.SendAsync("Runtime.enable");client.Event("Animation.animationCreated").OnEvent += (_, _) => Console.WriteLine("Animation created!");var response = await client.SendAsync("Animation.getPlaybackRate");var playbackRate = response.Value.GetProperty("playbackRate").GetDouble();Console.WriteLine("playback rate is " + playbackRate);await client.SendAsync("Animation.setPlaybackRate", new() { { "playbackRate", playbackRate / 2 } });
Methods
Added before v1.9 cdpSession.DetachAsync
Detaches the CDPSession from the target. Once detached, the CDPSession object won't emit any events and can't be used to send messages.
Usage
await CdpSession.DetachAsync();
Returns
Added in: v.1.30 cdpSession.Event
Returns an event emitter for the given CDP event name.
Usage
CdpSession.Event(eventName);
Arguments
Returns
Added before v1.9 cdpSession.SendAsync
Usage
await CdpSession.SendAsync(method, params);
Arguments
Protocol method name.
args [Map]?<string
, Args> (optional) Added in: v1.30#
Optional method parameters.
Returns
[JsonElement?]#