English · Node.js
Appearance
English · Node.js
Appearance
The CDPSession instances are used to talk raw Chrome Devtools Protocol:
session.send method.session.on method.Useful links:
const client = await page.context().newCDPSession(page);
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
});Detaches the CDPSession from the target. Once detached, the CDPSession object won't emit any events and can't be used to send messages.
Arguments
Protocol method name.
Optional method parameters.
signal AbortSignal (optional) Added in: v1.65
Allows to cancel the operation using an AbortSignal. If the signal is aborted, the operation will be aborted and throw an error.
timeout float (optional) Added in: v1.65
Maximum time in milliseconds to wait for the response. Defaults to 0 - no timeout.
Returns
Promise<Object>Emitted when the session is closed, either because the target was closed or session.detach() was called.
Event data
CDPSessionEmitted for every CDP event received from the session. Allows subscribing to all CDP events at once without knowing their names ahead of time.
Usage
session.on('event', ({ method, params }) => {
console.log(`CDP event: ${method}`, params);
});Event data
Object