Interface CDPSession

  • extends: [EventEmitter]

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:

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

Hierarchy

  • CDPSession

Properties

addListener: (<T>(event, listener) => CDPSession)

Type declaration

    • <T>(event, listener): CDPSession
    • Type Parameters

      • T extends symbol | keyof Events

      Parameters

      • event: T
      • listener: ((payload) => void)
          • (payload): void
          • Parameters

            • payload: T extends symbol
                  ? any
                  : Events[T extends keyof Events
                      ? T
                      : never]

            Returns void

      Returns CDPSession

off: (<T>(event, listener) => CDPSession)

Type declaration

    • <T>(event, listener): CDPSession
    • Type Parameters

      • T extends symbol | keyof Events

      Parameters

      • event: T
      • listener: ((payload) => void)
          • (payload): void
          • Parameters

            • payload: T extends symbol
                  ? any
                  : Events[T extends keyof Events
                      ? T
                      : never]

            Returns void

      Returns CDPSession

on: (<T>(event, listener) => CDPSession)

Type declaration

    • <T>(event, listener): CDPSession
    • Type Parameters

      • T extends symbol | keyof Events

      Parameters

      • event: T
      • listener: ((payload) => void)
          • (payload): void
          • Parameters

            • payload: T extends symbol
                  ? any
                  : Events[T extends keyof Events
                      ? T
                      : never]

            Returns void

      Returns CDPSession

once: (<T>(event, listener) => CDPSession)

Type declaration

    • <T>(event, listener): CDPSession
    • Type Parameters

      • T extends symbol | keyof Events

      Parameters

      • event: T
      • listener: ((payload) => void)
          • (payload): void
          • Parameters

            • payload: T extends symbol
                  ? any
                  : Events[T extends keyof Events
                      ? T
                      : never]

            Returns void

      Returns CDPSession

removeListener: (<T>(event, listener) => CDPSession)

Type declaration

    • <T>(event, listener): CDPSession
    • Type Parameters

      • T extends symbol | keyof Events

      Parameters

      • event: T
      • listener: ((payload) => void)
          • (payload): void
          • Parameters

            • payload: T extends symbol
                  ? any
                  : Events[T extends keyof Events
                      ? T
                      : never]

            Returns void

      Returns CDPSession

Methods

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

    Returns Promise<void>

  • Type Parameters

    • T extends keyof CommandParameters

    Parameters

    • method: T

      Protocol method name.

    • Optional params: CommandParameters[T]

      Optional method parameters.

      Optional

    Returns Promise<CommandReturnValues[T]>

Generated using TypeDoc