The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →To send a Chrome DevTools Protocol (CDP) command with Puppeteer, create a session for the target page with await page.createCDPSession(), then call await client.send('Domain.command', params). The command returns a promise for its result. Detach the session when you are done sending commands and receiving events.
Send a CDP command
This complete example assumes you already have a Puppeteer page object:
| # | Preview | Product | Price | |
|---|---|---|---|---|
| 1 |
|
Browser Automation Playbook: Production Engineering Edition | $170.00 | Buy on Amazon |
| 2 |
|
Python Browser Automation Cookbook: 50 Production Recipes using nodriver | $45.00 | Buy on Amazon |
| 3 |
|
Antiguraviti Burauza Kontororu (Japanese Edition) | $2.99 | Buy on Amazon |
As an Amazon Associate I earn from qualifying purchases.
const client = await page.createCDPSession();
try {
const result = await client.send('Runtime.evaluate', {
expression: '1 + 1',
});
console.log(result);
} finally {
await client.detach();
}
Page.createCDPSession() returns a Promise<CDPSession> attached to that page. CDPSession.send() takes the protocol method name and its parameters, and resolves with the method’s mapped result. The example illustrates the call shape; choose a command and parameter names supported by the Chrome version you run.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallFor current Puppeteer API details, see Page.createCDPSession() and CDPSession.send(). Those references displayed Puppeteer 25.12.0 when checked on October 3, 2026; check the documentation for the version installed in your project because API signatures and protocol support can change.
#1 Best Overall
Get a page and run the command
In a browser automation script, the session must be attached to the page that should receive the command. This runnable example launches a browser, opens a page, evaluates a simple expression through CDP, then cleans up both session and browser:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com');
const client = await page.createCDPSession();
try {
const result = await client.send('Runtime.evaluate', {
expression: '1 + 1',
});
console.log(result);
} finally {
await client.detach();
}
} finally {
await browser.close();
}
})();
Use your existing launch or connection setup if the browser is managed elsewhere; the CDP workflow begins once you have the intended page.
Choose the command and parameters
CDP methods are named as Domain.command, such as Runtime.evaluate. Pass the command’s parameters as the second argument, using the exact field names and value types in the protocol definition for the browser you are automating. The returned value depends on that command: retain it when you need the result, or await the call when completion is all that matters.
Commands and parameter schemas are browser-protocol details, not interchangeable guesses. A command may also require its protocol domain to be enabled before use; follow the requirements for that command and browser version.
Listen for protocol events
Use client.on() to handle events emitted by a protocol domain. Enable that domain first when its protocol definition requires it. Puppeteer’s documented example creates a session, enables the Animation domain, listens for an animation event, reads the playback rate, and sets it:
const client = await page.createCDPSession();
await client.send('Animation.enable');
client.on('Animation.animationCreated', event => {
console.log(event);
});
const { playbackRate } = await client.send('Animation.getPlaybackRate');
await client.send('Animation.setPlaybackRate', { playbackRate });
See the Puppeteer CDPSession class reference for its session and event examples. That page is the Next documentation, so confirm details against the Puppeteer release you use.
Detach when finished
Call await client.detach() when the session is no longer needed. Once detached, it cannot send commands and no longer emits events. A try/finally block, as in the examples above, ensures detachment even if a command fails.
Free tools Windows power users keep installed
One-click scans. No signup required.
Avoid the obsolete page-target pattern
Older examples may create a session with page.target().createCDPSession(). Puppeteer marks Page.target() obsolete and directs users to call Page.createCDPSession() directly. The legacy method is documented in the Page.target() reference (version 25.11.0 when checked October 3, 2026); use the direct page method in new code.
Troubleshooting
- The session cannot be created or commands fail: confirm that
pageis the intended, active Puppeteer page and that the browser connection is still open. - The command rejects or returns an error: verify the method spelling, parameter names and types against the protocol supported by the browser you run. Check whether the command’s domain must be enabled first.
- No event handler runs: subscribe with
client.on('Domain.eventName', handler), confirm the event name, and enable the relevant domain when required. A detached session cannot receive events. - Later commands fail after cleanup: detachment ends the session. Create a new session from the page if you need to resume CDP communication.
Or skip the browser setup
If your goal is a website screenshot rather than custom CDP control, ScreenshotNeo takes a screenshot or PDF from a single GET request. For example, save a WebP capture with cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for request options. It accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers report the page verdict and billing status. ScreenshotNeo also provides an MCP server with screenshot, page-info and PDF-capture tools for AI agents. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.
Frequently Asked Questions
What does CDP stand for?
CDP is the Chrome DevTools Protocol, the browser protocol that Puppeteer’s CDPSession can communicate with.
Can I reuse a detached CDPSession?
No. After detachment, that session cannot send commands or receive events; create another session from the page.
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.




