October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How to Send Chrome DevTools Protocol Commands with Puppeteer

Attach a page-scoped CDP session in Puppeteer, send protocol commands with send(), listen for events, and check compatibility and lifecycle details.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Puppeteer’s page-scoped CDP session: call await page.createCDPSession(), then send commands with await client.send('Domain.command', params). The returned promise resolves with the protocol response; subscribe to protocol events with client.on(). Detach the session when you are finished.

Send a CDP command from Puppeteer

This runnable Node.js example opens a page, attaches a Chrome DevTools Protocol (CDP) session, enables the Animation domain, listens for an event, reads a value, changes it, then detaches and closes the browser.

As an Amazon Associate I earn from qualifying purchases.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com');

  const client = await page.createCDPSession();
  try {
    await client.send('Animation.enable');

    client.on('Animation.animationCreated', event => {
      console.log('Animation created:', event);
    });

    const { playbackRate } = await client.send('Animation.getPlaybackRate');
    console.log('Playback rate:', playbackRate);

    await client.send('Animation.setPlaybackRate', {
      playbackRate: playbackRate / 2,
    });
  } finally {
    await client.detach();
  }
} finally {
  await browser.close();
}

Run it in a Node.js project with Puppeteer installed, using a package setup that supports ES modules (for example, a .mjs file). The try/finally blocks ensure the session is detached and the browser is closed even if a command fails. The sample uses the Animation domain; replace its methods and event with the ones required for your task.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand commands, results, and events

CDP groups methods and events into domains such as Page, Network, Runtime, and Animation. A command name is a string in the form Domain.method. Pass a parameter object when the method requires arguments; omit it for methods that take none.

  • await client.send('Animation.enable') enables the domain so its events can be observed.
  • await client.send('Animation.setPlaybackRate', { playbackRate: 0.5 }) sends a method with parameters.
  • await client.send('Animation.getPlaybackRate') resolves to the command’s protocol response object, which the example destructures to read playbackRate.
  • client.on('Animation.animationCreated', handler) registers an event listener. Use the event name associated with the domain and command you need.

Use the protocol mapping and documentation for your installed Puppeteer release to check method names and parameter shapes. Puppeteer can provide type checking for mapped methods in TypeScript; an unknown or unsupported method may not be caught until runtime.

Choose the right session target

Attach to a page

For commands that concern a page, use await page.createCDPSession(). It returns a CDPSession attached to that page.

Attach to another target

Use target.createCDPSession() when you need a session attached to a CDP target rather than the page API’s context. Targets can represent pages, frames, or workers, so target-level attachment can address contexts outside the page you are automating.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not use page.target() as the route to a session: Puppeteer marks that method obsolete and directs users to Page.createCDPSession().

Manage the session lifecycle and errors

Keep the session attached while you need to send commands or receive events. Once detached, it cannot send messages or emit events; create a new session if you need to resume protocol work. Await each send() call so command failures can be handled in the surrounding control flow.

For Puppeteer 25.12.0, the documented ConnectOptions default for protocolTimeout is 180,000 milliseconds per CDP call. This setting is version-sensitive; check the API reference for the Puppeteer release in your project before relying on that default or changing it.

Check compatibility before depending on a method

Puppeteer releases are paired with specific browser releases to preserve protocol compatibility. Puppeteer uses CDP by default when automating Chrome and also supports WebDriver BiDi. The CDP tip-of-tree reference changes frequently and may break; the stable 1.3 protocol is a smaller subset tagged at Chrome 64. Confirm that the command exists in the browser build you actually run and matches the protocol mapping for your Puppeteer version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Prefer Puppeteer’s higher-level API when it already performs the operation you need; direct CDP is useful for lower-level Chrome capabilities not exposed there.
  • Use CDP when Chrome-specific protocol functionality is required. If cross-browser automation matters, evaluate WebDriver BiDi and verify feature differences rather than assuming the same command is portable.
  • Align Puppeteer and browser versions, especially when using experimental or tip-of-tree methods.

Troubleshoot common CDP problems

  • “Method wasn’t found” or an equivalent protocol error: the method may not be available in that browser version, may be experimental, or may be misspelled. Check the domain and method against the installed browser’s protocol support and the matching Puppeteer references.
  • Parameters are rejected: verify the command’s required fields, value types, and nesting. Send a parameter object as the second argument to send(); do not assume similarly named methods share parameters.
  • No event arrives: check that you enabled the relevant domain when required, registered the listener before the action that triggers the event, and used the exact event name. Confirm the session is still attached.
  • Calls fail after detaching: a detached session cannot be reused. Create a new session with the appropriate page or target.
  • A call takes too long or times out: the command may be waiting on browser work or the protocol timeout. Check the installed Puppeteer release’s timeout configuration and whether the page or target is still responsive.
  • Works with one Chrome/Puppeteer pair but not another: protocol support is version-dependent. Check the exact browser and Puppeteer versions and avoid assuming that tip-of-tree commands are stable.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is simply to get a website screenshot, ScreenshotNeo provides a one-request API rather than a Puppeteer/CDP browser workflow. See the ScreenshotNeo API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.

Sign up for 1,000 free screenshots a month, with no card required.

Frequently Asked Questions

Can Puppeteer send CDP commands to Firefox?

The CDP session approach described here is for Chrome’s DevTools Protocol. Puppeteer also supports WebDriver BiDi; check the browser and feature support when cross-browser automation is required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I reuse a CDP session after calling detach()?

No. A detached session cannot send messages or emit events; create a new session for further protocol work.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.