Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › browser automation

How to Capture a Screenshot of a Chrome Extension Page with Puppeteer

By Freedom251 Team · · 6 min read

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

There are two ways to use Puppeteer with a Chrome extension page: run Puppeteer inside the extension using its experimental ExtensionTransport, or run Puppeteer in Node.js and automate a Chrome instance that has the extension loaded. The code and constraints differ, so first decide where Puppeteer will run.

Choose where Puppeteer runs

Workflow How Puppeteer reaches the page Main constraint
Inside the extension Connect to a tab with puppeteer-core and the experimental ExtensionTransport, which uses restricted chrome.debugger access. The transport works with one page at a time; use Chrome’s tabs API and a separate connection for another page.
In Node.js, testing the extension Launch Chrome with the extension loaded, find its popup target, convert the target to a Puppeteer Page, then take the screenshot. You must identify the intended popup target; a broad URL match can select the wrong page if multiple targets match.

The examples below follow the official Puppeteer documentation version 25.12.0. The extension transport is documented as experimental, and its API may change.

As an Amazon Associate I earn from qualifying purchases.

Run Puppeteer inside the extension

This is the interpretation to use when the extension itself needs to capture a tab. The official guide describes Chrome extensions as able to access the Chrome DevTools Protocol through chrome.debugger. This is not the same runtime as Node.js: bundle a browser-compatible build with a bundler such as Rollup or webpack, as the Puppeteer guide instructs, and request the necessary extension permissions for the Chrome APIs your extension uses.

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

Connect to a tab and capture it

Create or identify the tab with chrome.tabs before connecting. The following assumes that url is the address you want to capture and that the bundled browser entry point is available in your extension code:

import {
  connect,
  ExtensionTransport,
} from 'puppeteer-core/lib/puppeteer/puppeteer-core-browser.js';

const url = 'https://example.com';
const tab = await chrome.tabs.create({ url });

const browser = await connect({
  transport: await ExtensionTransport.connectTab(tab.id),
});

const [page] = await browser.pages();
const imageBytes = await page.screenshot({ type: 'png' });

imageBytes is a Uint8Array by default. If you need a base64 string instead, use await page.screenshot({ encoding: 'base64' }). If your extension should capture an existing tab rather than open a new one, obtain that tab with chrome.tabs and pass its ID to connectTab.

Respect the one-page transport limit

ExtensionTransport attaches to one page at a time. Do not use this connection as though it were a normal Node Puppeteer browser that can create and manage multiple pages. To capture another tab, use the Chrome tabs API to locate or create it, then establish a connection for that tab.

Rank #2
OFFO Shower Head Extension Arm, Shower Arm Extension Shower Head Extender Made of 304 Stainless Steel Shower Pipe Extension, Chrome 3 in
  • [Beautiful and Effective] It adopts special process technology with widened sealing surface of water outlet to ensure close contact with the sealing gasket of sprinkler. 95% of shower head can achieve good water sealing effect without thread seal tape, so there’s no need to worry about the beauty of bathroom will be affected by the residue of thread seal tapes.
  • [Durable and Safe] The pipe is made of marine-grade 304 stainless steel with over twice strength of ordinary brass, good resistance to acid, alkali and salt, long-term corrosion resistance to avoid shower head blockage due to rust residues, especially suitable for hard water and hot spring water.
  • [Multi-layer Electroplating] Multi-layer nickel-chromium electroplating process technology, nickel layer can resist corrosion with adhesion, chromium layer can resist scratches with shining effect. The layer is always bright and shining without falling off even after long period of use.
  • [Installation and Specifications] Detailed instructions ensure worry-free installation. The product is 3 in long, the thread specification of inlet is 1/2"-14 NPT, suitable for standard shower arm. The thread specification of outlet is 1/2"-14 NPT (compatible with 1/2" IPS thread), suitable for sprinkles of standard interface.
  • [After-sales Service] In case of any problems or complaints during use or installation, please don’t hesitate to contact us and we will respond with solutions within 24 hours. It’s always our persistence and belief to provide high-quality products and satisfactory customer services.

Run Puppeteer in Node.js to capture an extension popup

For automated testing, the more typical arrangement is to run Puppeteer in Node.js and launch Chrome with the unpacked extension loaded. The extension guide demonstrates launch({ enableExtensions: [pathToExtension] }); the popup then appears as a page target that can be converted into a Puppeteer Page.

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.

Launch, locate, and capture the popup

Use a popup URL condition that identifies your own extension. This example expects a popup file named popup.html and saves a PNG in the Node process’s current working directory:

Rank #3
OFFO Shower Head Extension Arm, Shower Arm Extension Shower Head Extender Made of 304 Stainless Steel Shower Pipe Extension, Chrome 6 in
  • [Beautiful and Effective] It adopts special process technology with widened sealing surface of water outlet to ensure close contact with the sealing gasket of sprinkler. 95% of shower head can achieve good water sealing effect without thread seal tape, so there’s no need to worry about the beauty of bathroom will be affected by the residue of thread seal tapes.
  • [Durable and Safe] The pipe is made of marine-grade 304 stainless steel with over twice strength of ordinary brass, good resistance to acid, alkali and salt, long-term corrosion resistance to avoid shower head blockage due to rust residues, especially suitable for hard water and hot spring water.
  • [Multi-layer Electroplating] Multi-layer nickel-chromium electroplating process technology, nickel layer can resist corrosion with adhesion, chromium layer can resist scratches with shining effect. The layer is always bright and shining without falling off even after long period of use.
  • [Installation and Specifications] Detailed instructions ensure worry-free installation. The product is 6 in long, the thread specification of inlet is 1/2"-14 NPT, suitable for standard shower arm. The thread specification of outlet is 1/2"-14 NPT (compatible with 1/2" IPS thread), suitable for sprinkles of standard interface.
  • [After-sales Service] In case of any problems or complaints during use or installation, please don’t hesitate to contact us and we will respond with solutions within 24 hours. It’s always our persistence and belief to provide high-quality products and satisfactory customer services.
import puppeteer from 'puppeteer';

const pathToExtension = '/absolute/path/to/your/extension';
const browser = await puppeteer.launch({
  enableExtensions: [pathToExtension],
  headless: true,
});

try {
  // Trigger the extension action here if your test has not opened the popup yet.
  const popupTarget = await browser.waitForTarget(
    target => target.type() === 'page' && target.url().endsWith('popup.html'),
  );
  const popupPage = await popupTarget.asPage();
  await popupPage.screenshot({ path: 'popup.png', type: 'png' });
} finally {
  await browser.close();
}

Replace the path and popup filename with those used by your extension. The target predicate shown is suitable only when it uniquely identifies the popup you want; refine it if your extension or test opens multiple matching pages. The official extension guide also documents accessing extension service workers, background pages, popup targets, and the extension action.

Make sure the popup is open

waitForTarget waits for a target to appear; it does not itself click the extension action. Your test must trigger the action or otherwise open the popup first. Arrange the trigger before waiting for the popup target, and make the target predicate specific enough to avoid matching an unrelated tab.

Rank #4
4-Piece 3/8" Drive Socket Extension Bar Set, Professional Socket Extension Set Include 3, 6, and 10 Inch Extensions and 3/8 Inch drive Universal Joint Sockets, Premium Cr-V Steel Construction
  • VERSATILE REACH - This extension set includes 3, 6, and 10-inch extension bars, providing you with the flexibility to access tight spaces and reach fasteners in hard-to-reach areas, making it perfect for auto repair and home improvement projects
  • FLEXIBLE CONNECTION - The included 3/8" drive universal joint socket allows you to work at various angles, offering flexibility for a wide range of repair and maintenance tasks, improving both convenience and overall productivity
  • PREMIUM DURABILITY - Made from high-quality, hardened chrome vanadium steel, this 3/8" socket extension set is designed for long-lasting performance with exceptional rust resistance, ensuring it can withstand demanding tasks for years
  • ANTI-SLIP GRIP - The chrome-plated, mirror-finished surface combined with an anti-slip design ensures easy maintenance and secure handling, giving you more control and preventing slippage during high-torque applications
  • EFFORTLESS PERFORMANCE - Featuring extension bars and a universal joint socket, this set locks securely into place, improving work efficiency by allowing you to quickly and precisely complete tasks without interruptions

Choose screenshot output and capture area

Page.screenshot() returns image bytes by default; set encoding: 'base64' when a string is required. Passing path writes the image to a file instead. A relative path is resolved from the process’s working directory.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Option Use
path Save the screenshot to a file; without it, the method returns image data.
type Select an image format such as png, jpeg, or webp, where supported by the documented options.
fullPage Capture the full document when set to true; the documented default is false.
clip Capture a specified rectangular area rather than the default page area.
omitBackground Omit the default page background where a transparent result is wanted and supported by the selected format.
encoding Choose the output representation: bytes by default, or a base64 string when requested.

For a popup, decide whether you need the visible popup viewport or the full document. Do not set fullPage: true automatically: the default screenshot is not full-page. Puppeteer’s documented captureBeyondViewport default is false when no clip is supplied and true when a clip is supplied.

Best Value
MIXPOWER 9-Piece Extension Bar Set, 1/4", 3/8" and 1/2" Drive Socket Extension Bar, CR-V, Mirror Finish
  • 【Premium CR-V】Made from premium chrome vanadium steel with mirror polish finish for industrial, mechanic or construction work.
  • 【Set Include】3-piece 1/4" Dr.: 2-inch, 4-inch, 6-inch, 3-piece 3/8" Dr.: 3-inch, 6-inch, 10-inch, 3-piece 1/2" Dr.: 3-inch, 5-inch, 10-inch.
  • 【Enhanced Torque Force】The spring-loaded detent ball system at the end of bars locks socket into place for security and prevents dropping. Knurled handle for easy hand turning loosened fasteners.
  • 【Easy to Organize】It comes with a durable blow-molded carrying case for easy transportation, safe storage, and quick organization.
  • 【Service Guarantee】All MIXPOWER Tools meet or exceed ANSI performance standards. It comes with 1 year quality guarantee.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common problems and fixes

  • No matching popup target: the popup has not been opened, or the URL predicate does not match its actual URL. Trigger the action before waiting and inspect the extension’s popup URL to tighten the predicate.
  • The wrong page is captured: more than one target satisfies the predicate. Match a distinctive extension URL or other known property rather than only checking that the target is a page.
  • ExtensionTransport cannot connect: confirm the tab exists and pass its tab ID. Check the extension’s debugger-related permissions and remember that this transport is experimental and restricted to one page at a time.
  • Browser import fails in extension code: the browser entry point is not a regular Node import. Bundle the browser-compatible Puppeteer build for the extension runtime as the official guide describes.
  • The screenshot is only the visible area: set fullPage: true when the complete document is required; fullPage defaults to false.
  • No image file appears: without path, screenshot data is returned to the caller rather than saved. For relative paths, check the Node process’s working directory.

Or skip the browser setup

If the goal is a screenshot of a public website—not an extension popup or other Chrome extension UI—ScreenshotNeo can return an image from one GET request. It is a website screenshot API and MCP server, not a way to capture an extension page inside Chrome. Its API accepts options for formats including PNG, JPEG, and WebP; see the ScreenshotNeo API documentation for parameters and setup.

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

ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

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

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

Frequently Asked Questions

Can Puppeteer capture a Chrome extension popup from Node.js?

Yes. Launch Chrome with the unpacked extension loaded, wait for the popup target, convert it with asPage(), and call screenshot().

Can Puppeteer running inside an extension create another page through ExtensionTransport?

No. The documented transport is limited to one page at a time; use Chrome’s tabs API and another connection for a different tab.

What does Puppeteer return from screenshot() by default?

A Uint8Array. Request encoding: 'base64' for a base64 string.

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.

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

browser automationChrome ExtensionsJavaScriptPuppeteerscreenshots

Leave a Reply

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

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.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.