Skip to content

ICDPSession

Namespace: PuppeteerSharp

public interface ICDPSession : ICDPConnection

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

  • Protocol methods can be called with CommandOptions) method.
  • Protocol events, using the MessageReceived event.

Documentation on DevTools Protocol can be found here: <a href=“https://chromedevtools.github.io/devtools-protocol/"&gt;https://chromedevtools.github.io/devtools-protocol/&lt;/a>.

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)
});

Derived: BidiCdpSession, CDPSession, CdpCDPSession

View source

Made with love by Dario Kondratiuk