Windows 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 reinstallCrashes, 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 minuteUse Puppeteer’s Page.createCDPSession() to attach a Chrome DevTools Protocol (CDP) session to a page, then call CDPSession.send() with the protocol method and its parameters. For example:
const client = await page.createCDPSession();
const result = await client.send('Runtime.evaluate', {
expression: '1 + 1',
});
console.log(result);
await client.detach();
Send a command through a page’s CDP session
A Puppeteer CDPSession is the API object for raw Chrome DevTools Protocol communication. Start with a Puppeteer Page, create a session, and await send(method, params). The returned promise resolves with the command’s result. The method name and parameter names must match the protocol command supported by the browser you are using.
| # | 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 |
const client = await page.createCDPSession();
const result = await client.send('Runtime.evaluate', {
expression: '1 + 1',
});
console.log(result);
await client.detach();
See Puppeteer’s Page.createCDPSession() and CDPSession.send() references for the API signatures. The references reviewed for this guide displayed Puppeteer 25.12.0; check the documentation for your installed Puppeteer version because signatures and protocol support can change.
Complete example, including browser setup
This runnable CommonJS example launches Chromium, opens a page, sends Runtime.evaluate, prints the returned result, and closes the browser. It assumes Puppeteer is installed in the project with npm install puppeteer.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
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: 'document.title',
returnByValue: true,
});
console.log(result.result.value);
} finally {
await client.detach();
}
} finally {
await browser.close();
}
})().catch(error => {
console.error(error);
process.exitCode = 1;
});
The example evaluates JavaScript in the page’s runtime and requests a by-value result, so the title is available at result.result.value. Choose the CDP command and parameters for the task at hand; this example illustrates the session pattern, not every command’s parameter schema.
Subscribe to CDP events
For commands that produce protocol events, register a listener with client.on(eventName, handler). Enable the relevant protocol domain first if its protocol definition requires it. Puppeteer’s documented example enables the Animation domain, listens for a created animation, and uses the playback rate returned by a command:
const client = await page.createCDPSession();
client.on('Animation.animationCreated', event => {
console.log('Animation created:', event);
});
await client.send('Animation.enable');
const { playbackRate } = await client.send('Animation.getPlaybackRate');
await client.send('Animation.setPlaybackRate', { playbackRate });
await client.detach();
Event names, command names, and parameter shapes are defined by the protocol and may vary with browser support. Puppeteer’s CDPSession class reference documents sending protocol methods and subscribing with CDPSession.on.
Detach when finished
Call await client.detach() when you are done with the session. A detached session cannot send commands and no longer emits events. Use try/finally when command execution may fail, so cleanup still happens. If the browser or target is closing, cleanup behavior may depend on that lifecycle; avoid trying to reuse a detached session.
Use the current session-creation method
For a page-level session, use await page.createCDPSession(). Older examples may show page.target().createCDPSession(), but Puppeteer marks Page.target() obsolete and directs users to the direct page method instead. See the Page.target() reference.
Troubleshooting
- “Method not found” or an unsupported command: Confirm the protocol method is available in the browser version and target you launched, and verify its exact domain and method spelling.
- Command rejects or parameters are invalid: Check the command’s protocol definition for required parameter names and types. Do not assume a parameter from a different CDP method applies here.
- No event arrives: Confirm you attached the listener to the same session, used the exact event name, and enabled the relevant protocol domain when required.
- Commands fail after cleanup: A detached session cannot send commands. Create a new session for subsequent protocol work.
- Examples using
page.target()do not fit current code: Replace the obsolete pattern withawait page.createCDPSession().
Or skip the browser setup:
If your goal is a website screenshot rather than arbitrary CDP work, ScreenshotNeo offers a one-request screenshot API. Its cleanup options accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, with the result identified in response headers. It also provides an MCP server for AI agents, and the free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for request options. ScreenshotNeo is a screenshot API, not a replacement for CDP commands when you need direct browser-protocol control. Sign up for 1,000 free screenshots a month with no card.
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.

