class: CDPSession

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

  • protocol methods can be called with session.send method.
  • protocol events can be subscribed to with session.on method.

Useful links:

  1. const client = await page.context().newCDPSession(page);
  2. await client.send('Animation.enable');
  3. client.on('Animation.animationCreated', () => console.log('Animation created!'));
  4. const response = await client.send('Animation.getPlaybackRate');
  5. console.log('playback rate is ' + response.playbackRate);
  6. await client.send('Animation.setPlaybackRate', {
  7. playbackRate: response.playbackRate / 2
  8. });

cdpSession.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.

cdpSession.send(method[, params])