DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › authentication

How to Take a Screenshot of a Password-Protected 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.

First identify what kind of password protection the page uses. For a browser-native HTTP authentication challenge, call Puppeteer’s page.authenticate() before navigating. For an HTML login form, use the site’s authorized sign-in flow or an authorized existing session instead—page.authenticate() does not fill web forms. In either case, verify that the protected content actually loaded before capturing it with page.screenshot().

Choose the right authentication method

What you see What to do
A browser-native username and password challenge Use page.authenticate() with the credentials set before page.goto().
Username and password fields rendered within the website Complete the site’s normal authorized login flow, or use an authorized session. The form, redirects, MFA and anti-automation behavior are site-specific.

Puppeteer documents page.authenticate() for HTTP authentication. It enables request interception behind the scenes, which may affect performance. It is not a general-purpose way to log in to an application form. The Puppeteer API documentation cited here is version 25.12.0; check the API reference for the version installed in your project: Puppeteer Page class.

As an Amazon Associate I earn from qualifying purchases.

Capture a page protected by HTTP authentication

This ES module example supplies credentials before navigation, checks the navigation response when one is available, waits for a marker that should exist only on the authenticated page, and then saves a full-page PNG.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.setViewport({ width: 1440, height: 1000 });

  // Store credentials outside source code, for example in environment variables.
  await page.authenticate({
    username: process.env.PAGE_USERNAME,
    password: process.env.PAGE_PASSWORD,
  });

  const response = await page.goto(process.env.PAGE_URL, {
    waitUntil: 'domcontentloaded',
  });

  if (response && !response.ok()) {
    throw new Error(`Navigation returned HTTP ${response.status()}`);
  }

  // Replace with a stable selector present only on the authorized page.
  await page.waitForSelector('[data-page-ready="true"]', { visible: true });
  await page.screenshot({ path: 'protected-page.png', fullPage: true });
} finally {
  await browser.close();
}

Set PAGE_URL, PAGE_USERNAME and PAGE_PASSWORD in the process environment or a secret manager before running the script. Do not commit credentials to source control. Replace the example readiness selector with a stable element from the page you control or are authorized to access. Puppeteer documents the authentication method and screenshot options in its Page API; its screenshots guide demonstrates navigation followed by capture.

#1 Best Overall
Sale
Logitech Brio 101 Full HD 1080p Webcam for Streaming and Meetings - Black | 1080p with auto-light correction, built-in mic, privacy shutter, USB-A, compatible with Teams, Google Meet, Zoom and more
  • Compatible with Nintendo Switch 2’s new GameChat mode
  • Auto-Light Balance: RightLight boosts brightness by up to 50%, reducing shadows so you look your best—compared to previous-generation Logitech webcams (1)
  • Privacy with a Slide: The integrated webcam cover makes it easy to get total, reliable privacy when you're not on a video call
  • Built-In Mic: The built-in microphone lets others hear you clearly during video calls
  • Easy Plug-And-Play: The Brio 101 works with most video calling platforms, including Microsoft Teams, Zoom and Google Meet—no hassle; it just works

Make the success check prove access

A completed navigation is not proof that authentication succeeded. The server might have redirected to a login page, returned an access-denied page, or served an expired-session screen. Wait for an expected protected-page heading, data marker or other authenticated-only content. A login form disappearing can help as a secondary check, but should not replace a positive check for the intended content. The right selector depends on the site.

Capture a page that uses an HTML login form

Use the website’s normal authorized sign-in flow. There is no universal set of selectors or form-submission steps: field names, buttons, MFA, identity-provider redirects and anti-automation controls differ by site. After signing in, navigate to the target URL if the flow did not already take you there, then wait for a site-specific element that confirms the protected content is present before taking the screenshot.

Rank #2
Sale
Logitech C270 720p Webcam Plug-and-Play Wide Screen Video Calling - Black | Auto-Light Correct, Noise-Reducing Mic, Zoom, Microsoft, Teams, Skype, Nintendo Switch 2 New GameChat Mode, PC Mac compatible
  • Compatible with Nintendo Switch 2’s new GameChat mode
  • Crisp HD 720p/30 fps video calls with diagonal 55° field of view and auto light correction. Compatible with popular platforms including Skype and Zoom.
  • The built-in noise-reducing mic makes sure your voice comes across clearly up to 1.5 meters away, even if you’re in busy surroundings.
  • C270’s RightLight 2 feature adjusts to lighting conditions, producing brighter, contrasted images to help you look good in all your conference calls.
  • The adjustable universal clip lets you attach the camera securely to your screen or laptop, or fold the clip and set the webcam on a shelf. You’re always ready for your next video call.

If clicking the login control triggers navigation, start the navigation wait at the same time as the click so the event is not missed:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await Promise.all([
  page.waitForNavigation(),
  page.click('YOUR_LOGIN_BUTTON_SELECTOR'),
]);

// This must identify expected authenticated content, not just navigation completion.
await page.waitForSelector('YOUR_PROTECTED_CONTENT_SELECTOR', { visible: true });
await page.screenshot({ path: 'protected-page.png', fullPage: true });

Replace both selectors and any form-handling steps with those appropriate to the authorized site. Puppeteer’s Page API documents navigation-related methods; the content check remains a separate, site-specific step.

Rank #3
Sale
NexiGo N60 1080P Webcam with Microphone, Software Control & Privacy Cover, USB HD Computer Web Camera, Plug and Play, for Zoom/Skype/Teams, Conferencing and Video Calling
  • 【Full HD 1080P Webcam】Powered by a 1080p FHD two-MP CMOS, the NexiGo N60 Webcam produces exceptionally sharp and clear videos at resolutions up to 1920 x 1080 with 30fps. The 3.6mm glass lens provides a crisp image at fixed distances and is optimized between 19.6 inches to 13 feet, making it ideal for almost any indoor use.
  • 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 8, 10 & 11 / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
  • 【Built-in Noise-Cancelling Microphone】The built-in noise-canceling microphone reduces ambient noise to enhance the sound quality of your video. Great for Zoom / Facetime / Video Calling / OBS / Twitch / Facebook / YouTube / Conferencing / Gaming / Streaming / Recording / Online School.
  • 【USB Webcam with Privacy Protection Cover】The privacy cover blocks the lens when the webcam is not in use. It's perfect to help provide security and peace of mind to anyone, from individuals to large companies. 【Note:】Please contact our support for firmware update if you have noticed any audio delays.
  • 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 10 & 11, Pro / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.

Reuse an authorized session carefully

If you reuse a signed-in browser session, use the Browser or BrowserContext cookie APIs appropriate to your installed Puppeteer version. The current Page API marks page-level cookie methods as deprecated and points to Browser or BrowserContext methods. Cookies and persisted browser profiles can grant account access: keep them private, do not log or publish their values, and use only sessions you are authorized to use.

Wait for the right moment and choose what to capture

  • Wait for a meaningful condition. waitForSelector(selector, { visible: true }) can wait for a visible target. Prefer an authenticated-content marker, and add any site-specific wait needed for the content to finish rendering. See Puppeteer’s waitForSelector reference.
  • Use network idle selectively. Puppeteer’s screenshots guide shows waitUntil: 'networkidle2' as one possible navigation strategy. It does not prove login succeeded, and pages with long-lived connections may not be a good fit for network-idle waits.
  • Capture a whole page or an element. Use page.screenshot({ path: 'protected-page.png', fullPage: true }) for content beyond the viewport. For a narrower artifact, the guide documents ElementHandle.screenshot(); choose a target that excludes unrelated sensitive material.
  • Protect the resulting image. Avoid capturing password fields, tokens or other secrets, especially if the screenshot will be shared. Limit the capture to the content needed.

Troubleshoot common failures

Symptom Likely cause What to check or change
The browser-native credentials challenge remains, or access is rejected. The credentials are wrong, apply to a different host, or the page uses a form rather than HTTP authentication. Confirm the challenge type and credentials, and call page.authenticate() before navigation. Use the site’s form flow if credentials are entered in page fields. See the Page API.
The screenshot contains a login page or access-denied response. Navigation finished, but the authenticated state was never confirmed. Check the response status and final page where appropriate, then wait for a selector that identifies expected protected content. waitForSelector() is documented in the Puppeteer reference.
The screenshot is missing content or catches the page mid-render. The capture started before the relevant content was ready. Wait for a page-specific ready marker or content selector. Consider a navigation wait such as networkidle2 only if it suits the page; long-lived connections can make network-idle waits unsuitable. See the screenshots guide.
Authentication makes the workflow slower. page.authenticate() turns on request interception internally. Account for the possible performance effect documented in the Page API; do not assume it is a failure.
Login stalls at MFA or an identity-provider redirect. The site requires steps specific to its authentication provider or policy. Follow the authorized provider flow and use an approved test account or session. Puppeteer’s cited API documentation does not promise automatic handling of a site’s MFA behavior.

Or skip the browser setup

If you have an authorized URL and need a screenshot without building a Puppeteer login workflow, ScreenshotNeo is a screenshot API and MCP server. Its one-call API example is below; see the ScreenshotNeo documentation for request options.

Rank #4
Sale
EMEET C960 1080P Webcam with Microphone, 2 Mics, 90° FOV, Computer Camera | USB Type-A & A-to-C Adapter, Fixed Focus, Plug&Play for Zoom/Teams/Facetime/YouTube/Google Meet/Switch 2 Camera, 2025 Version
  • 1080P Webcam with Cover for Video Calls - EMEET computer webcam provides design and Optimization for professional video streaming. Realistic 1920 x 1080p video, 5-layer anti-glare lens, providing smooth video. C960 computer camera delivers 1920x1080 video with fixed focus (11.8–118.1 inches), so as to provide a clearer image. C960 USB webcam has a cover and can be removed automatically to meet your needs for privacy. For optimal image performance, use the webcam in a well-lit environment.
  • Built-in 2 Omnidirectional Mics - EMEET webcam with microphone for desktop features 2 built-in omnidirectional microphones, picking up your voice to create clear audio for communication. When installing the webcam, select EMEET C960 as the default microphone input device in your computer and video applications and select C960 as the default device in Zoom/Teams and ensure microphone permissions are enabled for proper use. Please note that C960 does not include built-in speakers.
  • Automatic Light Adjustment - Automatic exposure adjustment is applied in EMEET HD webcam 1080p so that the streaming webcam can deliver stable image performance. EMEET C960 camera for computer also features color adjustment and exposure optimization to help you look your best. For optimal video quality, it is recommended to use the webcam in normal or well-lit environments and select suitable video settings in your application. Proper lighting helps achieve a clearer and more balanced image.
  • Plug-and-Play & Upgraded USB Connectivity - New C960 webcam features both USB Type-A & A-to-C adapter connections for wider compatibility. For stable performance, connect the webcam directly to the computer's main USB port and ensure the device is recognized correctly. If a hub or docking station is used, please ensure it provides sufficient power and stable data transmission, as limited ports may affect performance. 90° wide-angle lens captures more participants without frequent adjustments.
  • High Compatibility & Multi Application - C960 webcam for laptop is compatible with Windows 10/11, macOS 10.14+, and Android TV 7.0+. Not supported: Windows Hello, TVs, tablets, or game consoles. It works with Zoom, Teams, Facetime, Google Meet, YouTube and more. Please select C960 webcam as the default camera and microphone device in your application and ensure camera/microphone permissions are enabled, especially on macOS. (Tips: Incompatible with Windows Hello)
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Adapt the target URL and provide your API key. ScreenshotNeo accepts cookie and authorization options for capture; it removes cookie/consent banners, newsletter popups and chat widgets before the shot, with each cleanup step configurable. Bot checks, blank pages and failed loads are not billed. Its MCP server provides screenshot tools for Claude, Cursor and other MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

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.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month without a card.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently Asked Questions

Does Puppeteer’s page.authenticate() log in to a website form?

No. It is for HTTP authentication challenges. Use the website’s authorized form or session flow for an HTML login page.

Best Value
Logitech C920x HD Pro PC Webcam Full 1080p/30fps Video - Black | 30fps Video, Clear Audio, Light Correction, Works with Teams, Meet, Zoom, Nintendo Switch 2, Mac, Tablet
  • Compatible with Nintendo Switch 2’s new GameChat mode
  • HD lighting adjustment and autofocus: The Logitech webcam automatically fine-tunes the lighting, producing bright, razor-sharp images even in low-light settings. This makes it a great webcam for streaming and an ideal web camera for laptop use
  • Advanced capture software: Easily create and share video content with this Logitech camera that is suitable for use as a desktop computer camera or a monitor webcam
  • Stereo audio with dual mics: Capture natural sound during calls and recorded videos with this 1080p webcam, great as a video conference camera or a computer webcam
  • Full HD 1080p video calling and recording at 30 fps. You'll make a strong impression with this PC webcam that features crisp, clearly detailed, and vibrantly colored video

Does networkidle2 confirm that the protected page is authenticated?

No. It is a possible timing strategy, not an authentication check; wait for content that identifies the intended protected page.

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.

authenticationbrowser automationNode.jsPuppeteerweb screenshots

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair 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.