Halloween 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 PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › authentication

How to Capture a Chromium Screenshot of a Page Behind a Login

By Freedom251 Team · · 7 min read

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.

To capture a page behind a login, first authenticate a Chromium browser context, confirm that sign-in succeeded, then navigate to the protected page and take the screenshot. The screenshot call does not log you in. This guide uses Playwright with Node.js; it also covers saved sessions, HTTP authentication, Puppeteer, troubleshooting, and safe handling of credentials. Use automation only for accounts and pages you are authorized to access.

Choose the right authentication method

The login mechanism determines how to prepare Chromium. Use the site’s ordinary login form for an application sign-in, reuse Playwright storage state for repeat runs, or configure HTTP credentials when the server itself uses HTTP authentication. These approaches are not interchangeable.

As an Amazon Associate I earn from qualifying purchases.

Method Use it when What to verify
Web-form login The site presents a login page or redirects to an identity provider. A final URL or authenticated page element confirms sign-in completed.
Saved browser state You have already logged in and want later runs to reuse supported cookies and storage. The protected page still loads as authenticated; sessions can expire.
HTTP authentication The server challenges the browser with HTTP authentication rather than an application login form. The credentials work for the requested origin and resource.

Log in with Playwright and capture a screenshot

Install Playwright and its Chromium browser if they are not already available in your project. Set the environment variables below to the authorized login page, destination, and credentials. The example waits for the destination URL after submitting the form; adapt the selectors and success condition to the target site.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
npm install -D playwright
npx playwright install chromium
const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch({ headless: true });
  const context = await browser.newContext({
    viewport: { width: 1440, height: 1000 }
  });
  const page = await context.newPage();

  try {
    await page.goto(process.env.LOGIN_URL, { waitUntil: 'domcontentloaded' });
    await page.locator('input[name="username"]').fill(process.env.LOGIN_USER);
    await page.locator('input[name="password"]').fill(process.env.LOGIN_PASSWORD);
    await page.locator('button[type="submit"]').click();

    // Replace this URL with a stable post-login URL, or wait for a
    // recognizable element that only appears for authenticated users.
    await page.waitForURL(process.env.POST_LOGIN_URL, { timeout: 30000 });

    await page.goto(process.env.TARGET_URL, { waitUntil: 'networkidle', timeout: 60000 });
    await page.screenshot({ path: 'protected-page.png', fullPage: true });
  } finally {
    await browser.close();
  }
})();

Run it with the required environment variables set in your shell or secret manager. Never put real passwords directly in source code. If the login flow redirects through an identity provider or takes multiple steps to set cookies, wait for a dependable authenticated condition instead of assuming the submit click completed sign-in. A visible account control, page heading, or other stable element unique to the signed-in view can be a better signal than a URL.

#1 Best Overall
HexChecks Cr(VI) Hexavalent Chromium Testing Swabs, Pack of 10
  • Easy Testing: HexChecks Instant Swabs allow for quick and convenient testing for the presence of hexavalent chromium.
  • Efficient Pack: Comes in a pack of 10 swabs, providing ample supply for multiple testing needs.
  • Reliable Results: Utilizes a proven testing method to accurately detect hexavalent chromium traces.
  • Compact Design: Swabs are conveniently packaged in a compact box for easy storage and portability.
  • Straightforward Usage: Simply swab the desired surface and observe the color change for a clear indication of test results.

Choose the screenshot scope

  • Viewport: omit fullPage or set it to false to capture only the visible browser area at the chosen viewport.
  • Full page: set fullPage: true when content below the fold belongs in the artifact.
  • One element: use await page.locator('.report').screenshot({ path: 'report.png' }); with a selector for the component you need.

For visual comparisons, keep the viewport and execution environment consistent. Playwright notes that rendering can vary with the operating system, browser version, settings, hardware, power source, and headless mode: Playwright visual comparisons.

Reuse authenticated state for repeat captures

For recurring jobs, authenticate once, save the browser context state, then create later contexts from that file. Playwright recommends placing authentication files under a local playwright/.auth directory and excluding it from version control. The saved state may contain cookies and headers that can impersonate the account, so protect it like a password.

mkdir -p playwright/.auth
echo 'playwright/.auth' >> .gitignore

After the successful login in the first example, save state before closing the browser:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await context.storageState({ path: 'playwright/.auth/user.json' });

In a later run, create the context with that state:

Rank #2
HexChecks Hexavalent Chromium Test Swabs Bulk Pack (90 swabs), Cr6, Cr(VI), Colorimetric
  • DETECTION KIT: Complete hexavalent chromium testing kit includes Cr6 test swabs, neutralizer solution, and a convenient spray bottle for professional use
  • QUANTITY: Bulk pack contains 90 colorimetric swabs for extensive testing needs in industrial or laboratory settings
  • MADE IN USA: Manufactured in the United States by HexChecks, ensuring consistent quality and reliability in chemical detection
  • EASY TO USE: Simple colorimetric detection method provides quick visual indication of hexavalent chromium presence
  • COMPLETE PACKAGE: All-in-one testing solution with necessary components for immediate use in surface contamination detection
const context = await browser.newContext({
  storageState: 'playwright/.auth/user.json',
  viewport: { width: 1440, height: 1000 }
});

Storage-state support includes cookies, local storage, IndexedDB, and virtual WebAuthn credentials; which ones a site needs depends on its authentication implementation. Playwright’s standard storage-state flow does not automatically persist sessionStorage. If the target app relies on it, follow Playwright’s documented save-and-install workaround so the data is present before the app runs: Playwright authentication.

Saved sessions can expire or be revoked. If a run unexpectedly returns to the login page, repeat the supported login flow, verify success, and regenerate the state file. For parallel tests that modify shared server-side data, use separate test accounts where necessary rather than running them through one shared account. See the BrowserContext API for context and state details.

Use HTTP authentication when the server requires it

HTTP authentication is configured on the browser context, not by filling an application login form. With Playwright, supply credentials when creating the context:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const context = await browser.newContext({
  httpCredentials: {
    username: process.env.HTTP_USER,
    password: process.env.HTTP_PASSWORD
  }
});
const page = await context.newPage();
await page.goto(process.env.TARGET_URL);
await page.screenshot({ path: 'protected-page.png', fullPage: true });

With Puppeteer, its documented page method is page.authenticate(credentials). The method enables request interception behind the scenes, which may affect performance:

Rank #3
WaterWorks Low Range Chromium Test Strip| 30 Individually Wrapped Test Strips in Pocket Pack | Test Hexavalent Chromium | Lowest Detection
  • NEW! POCKET PACK: Avoid the bulk and SAVE with 30 individually wrapped test strips that fit in your pocket!
  • ✅ ENVIRONMENTALLY FRIENDLY: Reduce your plastic footprint with the biodegradable paper packaging.
  • ✅ DETECTION LEVELS: Chromium Hexavalent (as Cr-6): 0, 0.03, 0.05, 0.07, 0.1, 0.5, 1.0, 1.5 ppm
  • ✅ MADE IN THE USA FOR MAXIMUM ACCURACY - Test strips made overseas can be inaccurate, hard to read due to bleeding colors, fall apart, or do not even work. Instead choose quality with a leading American manufacturer of high-grade water testing products.
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  const page = await browser.newPage();
  try {
    await page.authenticate({
      username: process.env.HTTP_USER,
      password: process.env.HTTP_PASSWORD
    });
    await page.goto(process.env.TARGET_URL, { waitUntil: 'networkidle0' });
    await page.screenshot({ path: 'protected-page.png', fullPage: true });
  } finally {
    await browser.close();
  }
})();

References: Playwright BrowserContext API, Puppeteer screenshots guide, and Puppeteer Page API.

Troubleshoot failed or incorrect captures

Symptom Likely cause Fix
Screenshot shows the login page Sign-in failed, the success wait was too early, or saved state expired. Check the login response and credentials, wait for a final URL or authenticated element, and refresh stored state after a successful login.
Login succeeds manually but automation fails The site may require a multi-step identity flow, MFA, CAPTCHA, or a site-specific supported interaction. Use the application’s permitted test or automation path and verify each step. Do not assume a generic form selector works for every identity provider.
Page is partly loaded or images are missing The chosen readiness condition may occur before content finishes rendering, or the page loads content lazily. Wait for a page-specific selector or needed content before capturing; use a suitable readiness condition for the site’s network behavior.
Saved state does not persist sign-in The app may depend on session storage or another mechanism not covered by the saved state. Confirm the app’s authentication model; if it uses session storage, use Playwright’s documented workaround rather than assuming the standard state file contains it.
HTTP-auth capture is slow Puppeteer’s page.authenticate() uses request interception. Account for the interception overhead, or use the framework’s appropriate context-level HTTP-auth configuration.
Visual comparison differs between runs Browser, operating system, settings, hardware, power source, or headless mode changed. Record or pin the relevant browser and runtime versions and keep the viewport and execution environment consistent.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Protect credentials and screenshots

  • Use a test account where possible and only access pages you are authorized to capture.
  • Keep state files, cookies, authorization headers, and passwords out of source control; restrict access to stored files.
  • Limit access to screenshots too: they can expose private page contents even when the login credentials remain secret.
  • Do not share one account across parallel tests if those runs can alter shared server-side data.

Playwright explicitly warns that saved authentication state can enable account impersonation: Authentication documentation. Puppeteer’s security policy also discusses responsible use of browser automation capabilities: Puppeteer Security Policy.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. For a public target, one GET request returns an image or PDF; it does not replace the authenticated browser-session workflow above for a protected page that requires your account’s login state.

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

Example cURL request for a public page (see the ScreenshotNeo API documentation):

Rank #4
Industrial Test Systems WaterWorks 480047 Chromium (Chromate), 1 Minute and 17 Seconds Test Time, 0.1-50mg/L Range (Bottle of 50)
  • ✔EASY TO USE: Single dip and read test strip procedure and optimized color chart make the product ideal for technical and non technical users alike for detection of Chromium (as Cr+6) in water
  • ✔COMPLETE KIT: Bottle of 25 test strips with verified color chart bottle label for easy color matching
  • ✔ACCURATE AND RELIABLE: Components are tested by Quality Control personnel at each step and are rejected if they are outside of specifications. Standards are prepared using calibrated equipment, and concentrations are confirmed by recognized reference methods
  • ✔HIGHEST QUALITY: ITS, manufactures test strip products in their USA facility in an environment that allows for reproducibility, accuracy, and traceability based on Good Manufacturing Practices
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie/consent banners like a visitor and removes 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, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

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

Frequently Asked Questions

Does a screenshot API automatically sign in to a private website?

No. A capture request alone does not establish an authenticated browser session. The protected page must be accessed through an authorized login or a valid supported session.

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

Can I use this workflow with MFA?

Possibly, but the exact steps depend on the site’s identity provider and permitted test setup. The documentation cited here does not establish a universal MFA recipe; use the application’s supported automation path and confirm the signed-in state.

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.

authenticationbrowser automationChromiumPlaywrightPuppeteerscreenshots

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
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.