Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsUse await page.createCDPSession() to attach a Puppeteer CDPSession to a page, then call send() for Chrome DevTools Protocol commands and on() to handle protocol events. When you are finished, call detach(). This guide follows Puppeteer’s API Reference version 25.12.0 and uses the current page-scoped creation method.
What CDPSession does
Puppeteer describes CDPSession instances as being used “to talk raw Chrome Devtools Protocol.” The session gives your code access to CDP commands and events for its attached page; it is not a browser page or a replacement for Puppeteer’s higher-level page APIs. Its constructor is internal, so obtain sessions through Puppeteer’s creation methods rather than constructing or subclassing the class yourself. Puppeteer CDPSession class reference
As an Amazon Associate I earn from qualifying purchases.
Create a session for a page
For page-level work, call createCDPSession() on the Puppeteer Page object. It returns a promise that resolves to a session attached to that page. Page.createCDPSession() reference
Recommended Free Tools
const client = await page.createCDPSession();
For example, assuming page is already an open Puppeteer page, the following sequence follows the class reference’s Animation example and adds cleanup at the end:
#1 Best Overall
const client = await page.createCDPSession();
await client.send('Animation.enable');
client.on('Animation.animationCreated', () => {
console.log('Animation created!');
});
const response = await client.send('Animation.getPlaybackRate');
await client.send('Animation.setPlaybackRate', {
playbackRate: response.playbackRate / 2,
});
await client.detach();
The Animation domain example enables the domain, registers an event handler, reads the current playback rate, and sets it to half that rate. The example illustrates the API sequence; the documentation does not claim this exact combined snippet was tested as a unit. Protocol domains may have their own setup needs, so do not assume every command requires the same enable step. CDPSession class reference
Send a CDP command and receive its result
Call client.send(method, params) to invoke a protocol command. It returns a promise for the command’s mapped result, so use await when subsequent code depends on that result. For example, the Animation calls above await both the playback-rate query and the command that changes it. CDPSession.send() reference
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
The method is typed around Puppeteer’s protocol command mapping: the command string determines the corresponding parameter and result types. Both params and options are optional in the method signature. The method reference does not give additional explanatory descriptions for those parameters, so check the relevant protocol command’s requirements when deciding what to pass.
Listen for CDP events
Register a handler with client.on(event, handler). In the example, the handler listens for Animation.animationCreated after the Animation domain is enabled. Choose the event name and any required domain setup for the CDP feature you are using; the example is specific to Animation rather than a universal setup recipe. The event subscription API is documented on the CDPSession class page.
Rank #3
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Choose the right session scope
| Creation method | Attachment scope | When to use it |
|---|---|---|
page.createCDPSession() |
The page | Use when the protocol work is for a Puppeteer page. This is the direct documented route for a page-scoped session. Reference |
target.createCDPSession() |
A target | Use when you specifically need a session attached to a target. Puppeteer defines targets as debuggable entities such as frames, pages, or workers; the Target method reference documents target-scoped creation. Its API page identifies version 25.10.0, so do not assume that page was synchronized with every 25.12.0 reference. Target.createCDPSession() reference · API Reference |
Do not use page.target().createCDPSession() as the preferred page route. In the version 25.12.0 documentation, Page.target() is marked obsolete and points readers to Page.createCDPSession() for creating a session. The same page points to the PageEvent.Popup event for identifying pages spawned by the current page. Page.target() reference
Detach when the session is no longer needed
Call await client.detach() at the end of the session’s useful lifetime. Once detached, the session emits no more events and cannot send further messages. Put cleanup at the point where the code has finished using that session; do not try to reuse it afterward. CDPSession.detach() reference
Rank #4
Timeouts and troubleshooting
- Session creation or a command fails: Confirm the page is available and that the command is valid for the attached target. CDP commands and events are protocol-level interfaces; a session does not make an unsupported command valid.
- No event arrives: Check the event name and whether the relevant protocol domain needs enabling. The documented Animation example calls
Animation.enablebefore listening; that example does not establish identical setup requirements for all domains. - A send fails after cleanup: A detached session cannot send messages. Create and use a valid session for the work rather than retaining a detached one.
- A protocol call takes longer than expected: Puppeteer’s version 25.12.0
ConnectOptionsreference documentsprotocolTimeoutas the timeout for individual protocol calls, with a default of 180,000 milliseconds. This is a browser launch/connect configuration option, not a per-send()argument. ConnectOptions reference
Or skip the browser setup
If your goal is a website screenshot rather than custom CDP control, ScreenshotNeo is a screenshot API and MCP server for developers. A single GET request can return a screenshot or PDF, without requiring you to create and manage a Puppeteer browser session.
For example, this cURL request saves a WebP screenshot of Stripe. See the ScreenshotNeo API documentation for request options.
Best Value
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Frequently Asked Questions
Can I create a CDPSession directly with its constructor?
No. Puppeteer documents the constructor as internal; create a session through Puppeteer’s page or target methods.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Does every CDP domain need an enable command before listening?
The Animation example enables its domain, but the documentation does not establish that every domain has the same requirement. Check the setup for the protocol feature you are using.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




