puppeteer/website/versioned_docs/version-15.4.0/api/puppeteer.cdpsession.md
release-please[bot] f0c28085c0
chore(main): release 15.4.0 (#8668)
* chore(main): release 15.4.0

* chore: generate versioned docs

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
2022-07-13 15:52:23 +02:00

2.5 KiB

sidebar_label
CDPSession

CDPSession class

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

Signature:

export declare class CDPSession extends EventEmitter

Extends: EventEmitter

Remarks

Protocol methods can be called with CDPSession.send() method and protocol events can be subscribed to with CDPSession.on method.

Useful links: DevTools Protocol Viewer and Getting Started with DevTools Protocol.

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the CDPSession class.

Example

const client = await page.target().createCDPSession();
await client.send('Animation.enable');
client.on('Animation.animationCreated', () =>
  console.log('Animation created!')
);
const response = await client.send('Animation.getPlaybackRate');
console.log('playback rate is ' + response.playbackRate);
await client.send('Animation.setPlaybackRate', {
  playbackRate: response.playbackRate / 2,
});

Methods

Method Modifiers Description
connection()
detach() Detaches the cdpSession from the target. Once detached, the cdpSession object won't emit any events and can't be used to send messages.
id() Returns the session's id.
send(method, paramArgs)