The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →In current Puppeteer code, create a Chrome DevTools Protocol session with await page.createCDPSession(), send commands with await client.send('Domain.command', params), and detach the session when you are done. The examples below follow Puppeteer’s documented API, identified as version 25.12.0 for these methods.
Send a command through a page CDP session
A CDPSession sends raw Chrome DevTools Protocol (CDP) commands to the browser target associated with a Puppeteer page. Command calls are asynchronous: await send() to receive the response or catch a rejected Promise.
As an Amazon Associate I earn from qualifying purchases.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
let client;
try {
const page = await browser.newPage();
client = await page.createCDPSession();
await client.send('Runtime.enable');
const result = await client.send('Runtime.evaluate', {
expression: '2 + 2',
returnByValue: true,
});
console.log(result.result.value); // 4
} finally {
if (client) await client.detach();
await browser.close();
}
Runtime.enable enables that protocol domain. The second call evaluates an expression and asks for its value to be returned by value; with this response shape, the example prints 4. Check the protocol documentation for the browser version you run when choosing commands, parameters, and response fields.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsCreate the session with the current Page API
Use await page.createCDPSession(). Puppeteer’s documented signature is page.createCDPSession(): Promise<CDPSession>. The creation call itself is asynchronous, so await it before sending commands.
#1 Best Overall
Avoid using page.target().createCDPSession() in new code. Puppeteer marks Page.target() obsolete and recommends Page.createCDPSession() instead.
Send commands and handle their results
The documented send() method accepts a protocol method name, optional parameters, and optional command options, and returns a Promise for that command’s response. In current Puppeteer’s TypeScript protocol mapping, the method string constrains the corresponding parameter and return types:
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
const response = await client.send('Domain.command', {
// Parameters required by the chosen protocol command
});
Domain.command is a placeholder, not a runnable CDP method. Replace it and the parameters with a command supported by the Chrome version you use. For a command that accepts no parameters, omit the second argument.
Free tools Windows power users keep installed
One-click scans. No signup required.
In TypeScript, the documented generic signature ties the command name to its mapped parameter and return types: client.send<T extends keyof ProtocolMapping.Commands>(method, params?, options?). These types help with editor completion, but they do not guarantee that every command is available or behaves identically in every browser release.
Rank #3
Listen for CDP events
To receive events, enable the relevant protocol domain, register a listener, and then perform the action that may emit the event. Puppeteer’s CDPSession reference demonstrates this pattern with the Animation domain:
await client.send('Animation.enable');
client.on('Animation.animationCreated', event => {
console.log('Animation created:', event);
});
// Perform an action on the page that may create an animation.
Use the event name and event payload expected by the protocol version in use. Attach the listener before triggering the page action so you do not miss an event emitted earlier.
Rank #4
- 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
Detach the session when finished
Call await client.detach() when the session is no longer needed. After detaching, the session will not emit events and cannot send messages. If your code may throw, put cleanup in a finally block, as in the first example, and close the browser separately.
Common problems and fixes
- The session creation call is missing or not awaited: create it with
const client = await page.createCDPSession()before callingsend(). - A command rejects or its response shape differs from the example: verify the method, required parameters, and returned fields against the CDP protocol for the Chrome version paired with your Puppeteer installation. The sample’s
Runtime.evaluateresponse is specific to the options shown. - Events do not arrive: enable the relevant domain and register the listener before the action that should emit the event.
- Sending fails after cleanup: a detached session cannot send commands or emit events. Create a new session if you need to continue working.
- Older code uses
page.target(): migrate session creation topage.createCDPSession(), the current documented Page method.
Or skip the browser setup
If your goal is a website screenshot rather than sending arbitrary CDP commands, ScreenshotNeo provides a one-request screenshot API and an MCP server. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and responses identify the page verdict and billing status in headers.
For a screenshot, use this cURL call; replace the example URL with the page you need and provide your API key. 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
The same endpoint is available from Python or Node.js:
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots. Sign up for free ScreenshotNeo screenshots.
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.




