2022-08-06 14:49:20 +00:00
---
sidebar_label: CDPSession
---
# CDPSession class
The `CDPSession` instances are used to talk raw Chrome Devtools Protocol.
2022-10-24 14:31:12 +00:00
#### Signature:
2022-08-06 14:49:20 +00:00
```typescript
2023-09-19 13:03:19 +00:00
export declare abstract class CDPSession extends EventEmitter< CDPSessionEvents >
2022-08-06 14:49:20 +00:00
```
2023-09-19 13:03:19 +00:00
**Extends:** [EventEmitter ](./puppeteer.eventemitter.md )< [CDPSessionEvents](./puppeteer.cdpsessionevents.md)>
2022-08-06 14:49:20 +00:00
## Remarks
Protocol methods can be called with [CDPSession.send() ](./puppeteer.cdpsession.send.md ) method and protocol events can be subscribed to with `CDPSession.on` method.
Useful links: [DevTools Protocol Viewer ](https://chromedevtools.github.io/devtools-protocol/ ) and [Getting Started with DevTools Protocol ](https://github.com/aslushnikov/getting-started-with-cdp/blob/HEAD/README.md ).
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
```ts
2024-03-28 13:36:37 +00:00
const client = await page.createCDPSession();
2022-08-06 14:49:20 +00:00
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
2024-03-25 13:03:57 +00:00
< table > < thead > < tr > < th >
Method
< / th > < th >
Modifiers
< / th > < th >
Description
< / th > < / tr > < / thead >
< tbody > < tr > < td >
2024-04-11 16:51:07 +00:00
< span id = "connection" > [connection()](./puppeteer.cdpsession.connection.md)< / span >
2024-03-25 13:03:57 +00:00
< / td > < td >
< / td > < td >
< / td > < / tr >
< tr > < td >
2024-04-11 16:51:07 +00:00
< span id = "detach" > [detach()](./puppeteer.cdpsession.detach.md)< / span >
2024-03-25 13:03:57 +00:00
< / td > < td >
< / td > < td >
Detaches the cdpSession from the target. Once detached, the cdpSession object won't emit any events and can't be used to send messages.
< / td > < / tr >
< tr > < td >
2024-04-11 16:51:07 +00:00
< span id = "id" > [id()](./puppeteer.cdpsession.id.md)< / span >
2024-03-25 13:03:57 +00:00
< / td > < td >
< / td > < td >
Returns the session's id.
< / td > < / tr >
< tr > < td >
2024-04-11 16:51:07 +00:00
< span id = "send" > [send(method, params, options)](./puppeteer.cdpsession.send.md)< / span >
2024-03-25 13:03:57 +00:00
< / td > < td >
< / td > < td >
< / td > < / tr >
< / tbody > < / table >