Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › Chrome Extensions

How to Capture a Logged-In Page with Puppeteer and a Chrome Extension

By Freedom251 Team · · 6 min read

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

Use Puppeteer to launch Chrome with the unpacked extension enabled, sign in through the site’s permitted login flow using an isolated writable browser profile, wait for a page-specific signal that confirms you are authenticated, and capture with page.screenshot(). An extension can change or inspect page behavior, but it does not log you into the website.

What you need before you start

  • A current Puppeteer installation and an extension directory you are authorized to use.
  • Permission to access the account and capture the target page. Use the site’s normal login flow rather than attempting to bypass access controls.
  • A dedicated, writable userDataDir for the browser session. Treat this directory as sensitive: it can contain persistent session data.

Puppeteer’s current documentation identifies version 25.12.0. Check the version installed in your project and verify extension behavior in the browser environment you intend to deploy. The docs describe both loading an unpacked extension at launch and installing one at runtime. See Puppeteer’s Chrome Extensions guide and the LaunchOptions interface.

As an Amazon Associate I earn from qualifying purchases.

Load the extension and capture an authenticated page

The example below loads an extension at launch, navigates to a login page, waits for you to finish signing in, then opens a protected page and checks for a site-specific authenticated-state selector before saving a screenshot. Replace the URLs and selectors with ones appropriate for your site. The login form and authentication checks are deliberately site-specific; Puppeteer cannot infer that a page is logged in just because it loaded.

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

Install Puppeteer

In a Node.js project, install Puppeteer with your package manager, for example:

#1 Best Overall
Yubico - Security Key C NFC - Basic Compatibility - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key C NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key C NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key C NFC via USB-C and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.

npm install puppeteer

Runnable Node.js example

Save as capture.mjs. Set EXTENSION_PATH to the directory containing the unpacked extension, and adjust the login URL, target URL, and selectors. This version pauses for a human to complete the permitted login flow in the launched browser.

import puppeteer from 'puppeteer';
import path from 'node:path';

const extensionPath = path.resolve(process.env.EXTENSION_PATH ?? './my-extension');
const profilePath = path.resolve('./puppeteer-profile');

const browser = await puppeteer.launch({
  headless: false,
  userDataDir: profilePath,
  enableExtensions: [extensionPath],
});

try {
  const page = await browser.newPage();
  await page.goto('https://example.com/login', { waitUntil: 'domcontentloaded' });
  console.log('Complete the site login in the browser window.');

  // Replace this URL with a protected page on the site.
  await page.goto('https://example.com/account', { waitUntil: 'domcontentloaded' });

  // Replace with an element visible only after a successful login.
  await page.waitForSelector('[data-testid="account-home"]', { timeout: 60000 });

  await page.screenshot({ path: 'capture.png', fullPage: true });
  console.log('Saved capture.png');
} finally {
  await browser.close();
}

Puppeteer’s screenshot guide documents Page.screenshot(); fullPage: true captures the full scrollable page. See Screenshots. A selector that represents authenticated content is generally a more meaningful readiness check than network idleness alone: a site may keep requests open, or become network-idle while displaying a login or error page.

Choose how Puppeteer loads the extension

Known extension path at launch

Use enableExtensions: [extensionPath] when the extension path is fixed for the run. This keeps setup explicit at browser startup, as in the example above. The extension directory must remain available to the process.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Yubico - YubiKey 5C NFC - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified - Protect Your Online Accounts
  • POWERFUL SECURITY KEY: The YubiKey 5C NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
  • WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5C NFC secures 100+ of your favorite accounts, including email, password managers, and more
  • FAST & CONVENIENT LOGIN: Plug in your YubiKey 5C NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
  • MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
  • PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts

Install an extension at runtime

If your workflow needs to install an extension after launch, Puppeteer documents launching with enableExtensions: true, then calling browser.installExtension(extensionPath):

const browser = await puppeteer.launch({
  headless: false,
  userDataDir: './puppeteer-profile',
  enableExtensions: true,
});

const extension = await browser.installExtension('./my-extension');

Use the API supported by your installed Puppeteer version; extension behavior and API availability can vary by version and environment. The Chrome Extensions guide documents extension actions and contexts as well as loading methods.

Run an extension action when the page needs it

Loading an extension does not necessarily trigger its default action. If the extension must act on the current page, Puppeteer documents triggering its action with either of these forms:

Rank #3
Yubico - YubiKey 5 NFC - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-A or NFC, FIDO Certified - Protect Your Online Accounts
  • POWERFUL SECURITY KEY: The YubiKey 5 NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
  • WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5 NFC secures 100+ of your favorite accounts, including email, password managers, and more
  • FAST & CONVENIENT LOGIN: Plug in your YubiKey 5 NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
  • MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
  • PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts
await page.triggerExtensionAction(extension);
// Or, from the extension object:
await extension.triggerAction(page);

These methods control extension behavior; they do not authenticate the site account. The extension API also supports inspecting its service worker or background page and evaluating code in an extension content-script realm. Consult the version-specific Extension class reference before relying on those APIs.

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

Keep the website session separate from extension setup

A dedicated persistent userDataDir is useful when an authorized session needs to remain available between runs. A fresh profile is preferable when each run should start without retained browser state. In either case, protect the profile directory like a credential: restrict access, avoid committing it to source control, and remove it when it is no longer needed.

Do not assume that reusing a personal Chrome profile is safe or conflict-free; the cited Puppeteer documentation does not promise that. The target site’s own login flow determines whether the page is authenticated. Page.authenticate() is for HTTP authentication credentials, not ordinary web-app account login. Puppeteer documents cookie fields, but whether copying cookies is permitted or sufficient depends on the specific site and is not established as a general login method. See Page.authenticate() and the CookieData interface.

Rank #4
Yubico - Security Key NFC - Basic Compatibility - Multi-Factor Authentication (MFA) Key, Connect via USB-A or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key NFC via USB-A and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.

Headless mode, browser versions, and deployment

Puppeteer’s supported-browser documentation says Puppeteer v20 and later uses Chrome for Testing, and that headless and headful modes share the same browser code path. That does not guarantee every extension works identically in every deployment. Test the exact Puppeteer version, extension, and browser mode used in production. See Supported browsers.

Keep Chrome’s sandbox enabled in normal deployments. If Chrome fails to start in a container, investigate sandbox configuration and whether the profile directory is writable rather than treating --no-sandbox as a routine fix. Puppeteer’s Troubleshooting guide strongly discourages disabling the sandbox.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

The extension does not appear to load

  • Confirm that the path points to an unpacked extension directory, not a ZIP file or an unrelated parent folder.
  • Check that the extension files remain available to the browser process and that the Puppeteer version supports the configuration you are using.
  • If installing at runtime, launch with enableExtensions: true before calling browser.installExtension().

The capture shows a login page

  • Verify that login completed successfully and that the target URL belongs to the same authorized session.
  • Wait for a target-specific authenticated element or expected URL before taking the screenshot. A successful navigation event or network-idle state alone does not prove authentication.
  • Do not treat Page.authenticate() as a substitute for the site’s ordinary account login.

Chrome fails to launch or cannot use the profile

  • Check that userDataDir exists or can be created and is writable by the process.
  • Check container and host sandbox setup, and keep the sandbox enabled where possible.
  • Avoid simultaneous processes using the same persistent profile; use a separate profile for the capture job.

The extension loads but its behavior does not run

Loading and activation are separate. If the extension relies on its default action, trigger it with Puppeteer’s extension action API, then wait for the page change or other site-specific result before capturing. Consult the installed version’s extension API reference for supported behavior.

Best Value
FIDO2 U2F Security Key Passkey Two-Factor Authentication (2FA) USB Key PIN+Touch (Non-Biometric) USB-A Type TrustKey T110
  • Security Key : Protect your online accounts against unauthorized access by using FIDO2 and U2F authentication with T110. It's the world's most protective security key that works with windows, Mac OS, Linux as well as Chrome, Firefox, Edge and many other major browsers.
  • Certified with the new FIDO2 standard, T110 provides the benefit of fast login and strong protection against phishing, account takeover as well as many other online attactks.
  • Works with : Bank of America, Github, Google, Microsoft, DUO, Twitter, Facebook, Dropbox, Apple, ebay, BINANCE, mor and more.
  • Fits USB-A port : Insert the T110 security key into the USB-A port of each service and log in conveniently with one touch
  • For the driver download and user guide, please visit TrustKey Solutions Home support page.

Or skip the browser setup

For a one-request screenshot of a public page, ScreenshotNeo provides an API and an MCP server for AI agents. It is not a replacement for logging into a private account in your own browser session. A basic request is:

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 API documentation. ScreenshotNeo accepts cookie and 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, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status. Its MCP server includes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots.

Learn about ScreenshotNeo, or sign up free for 1,000 screenshots a month with no card.

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

Frequently Asked Questions

Can Puppeteer take screenshots with an extension in headless mode?

Puppeteer documents headless and headful modes using the same browser code path from v20 onward, but confirm that your particular extension works in the deployed version and mode.

Does loading a Chrome extension log me into a website?

No. Extension loading and extension actions are separate from the website’s authentication flow; sign in through a permitted method for that site.

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.

Chrome ExtensionsNode.jsPuppeteerscreenshotsweb automation

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.

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.