Table of Contents

Interface ICDPSession

Namespace
PuppeteerSharp
Assembly
PuppeteerSharp.dll

The CDPSession instances are used to talk raw Chrome Devtools Protocol:

Documentation on DevTools Protocol can be found here: https://chromedevtools.github.io/devtools-protocol/.

var client = await Page.Target.CreateCDPSessionAsync();
await client.SendAsync("Animation.enable");
client.MessageReceived += (sender, e) =>
{
     if (e.MessageID == "Animation.animationCreated")
     {
         Console.WriteLine("Animation created!");
     }
};
JObject response = await client.SendAsync("Animation.getPlaybackRate");
Console.WriteLine("playback rate is " + response.playbackRate);
await client.SendAsync("Animation.setPlaybackRate", new
{
    playbackRate = Convert.ToInt32(response.playbackRate / 2)
});
public interface ICDPSession : ICDPConnection

Properties

Id

Gets the session identifier.

string Id { get; }

Property Value

string

The session identifier.

LoggerFactory

Gets the logger factory.

ILoggerFactory LoggerFactory { get; }

Property Value

ILoggerFactory

The logger factory.

Methods

DetachAsync()

Detaches session from target. Once detached, session won't emit any events and can't be used to send messages.

Task DetachAsync()

Returns

Task

A Task that when awaited detaches from the session target.

Exceptions

PuppeteerException

If the Connection is closed.

Events

Disconnected

Occurs when the connection is closed.

event EventHandler Disconnected

Event Type

EventHandler

SessionAttached

Occurs when the session is attached to the target.

event EventHandler<SessionEventArgs> SessionAttached

Event Type

EventHandler<SessionEventArgs>

SessionDetached

Occurs when the session is detached from the target.

event EventHandler<SessionEventArgs> SessionDetached

Event Type

EventHandler<SessionEventArgs>