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

Use an authorized Playwright browser context to sign in, save its authentication state securely, reopen a context with that state, verify the target page is signed in, and capture the page with page.screenshot(). The state may include more than cookies, so treat it as a credential. This guide uses Playwright as the browser automation layer; an AI agent can direct the workflow, but should not receive or expose reusable login secrets unnecessarily.

How the workflow fits together

The reliable sequence is: authenticate in an isolated browser context, confirm the protected page is the intended signed-in view, then save the screenshot. A screenshot operation can succeed technically while capturing a login page, access-denied screen, or loading state, so page verification is part of the task rather than an optional check.

  1. Authenticate: use an account authorized to access the site. Sign in through the normal flow or load previously saved Playwright state.
  2. Navigate and verify: open the target URL and check a stable page identity or signed-in UI signal before capture.
  3. Capture and protect: choose viewport, full-page, or clipped capture, then store and share the resulting image with care appropriate to its contents.

Playwright browser contexts provide separate browser sessions; non-persistent contexts do not write browsing data to disk. See Playwright BrowserContext documentation.

What “authenticated cookies” may include

Playwright’s saved storage state can contain cookies and local storage, and can include IndexedDB or passkey-related state depending on the options and site authentication model. Some sites rely on session storage; Playwright describes session storage as domain-specific and does not persist it through the standard storage-state method. If restoring state fails, establish which mechanism the site uses rather than assuming a cookie is sufficient. See Playwright’s authentication guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Samsung Galaxy A17 5G Smart Phone 128GB US 1 Yr Manufacturer Warranty Black
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Set up Playwright and save state after sign-in

The following Node.js example creates an isolated context, lets you complete the site’s regular sign-in flow, waits for a signed-in page signal, and saves reusable state. Replace the example URL and selector with values appropriate to the site. Install Playwright with npm install playwright and ensure the browser is installed for your environment.

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch({ headless: false });
  const context = await browser.newContext();
  const page = await context.newPage();

  await page.goto('https://example.com/login', { waitUntil: 'domcontentloaded' });
  console.log('Complete the normal sign-in flow in the browser window.');

  // Replace with a selector that appears only after successful sign-in.
  await page.locator('[data-testid="account-menu"]').waitFor({ state: 'visible' });
  await context.storageState({ path: 'playwright/.auth/state.json' });

  await browser.close();
})();

Wait for a reliable post-login signal, not merely a fixed delay: redirects and authentication storage may not be complete when a login form disappears. Keep the state file out of source control, restrict access, and delete or refresh it when expired or no longer needed. Playwright warns that it can contain sensitive cookies and headers usable to impersonate the account. See the authentication guide.

Rank #2
Tracfone Motorola Moto G 2025, 64GB, Saphire Blue (Locked to
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Tracfone plan required, activating is easy, just 3 steps.
  • DISPLAY: Immersive viewing on a 6.7-inch super-bright 120Hz display with powerful stereo speakers and Bass Boost for cinematic entertainment.
  • CAMERA SYSTEM: Advanced 50MP Quad Pixel camera captures sharp, detailed photos and videos in any lighting condition
  • PERFORMANCE: Lightning-fast 5G connectivity paired with a powerful processor and RAM Boost for smooth multitasking.
  • BATTERY LIFE: Long-lasting 5000mAh battery with TurboPower charging technology delivers hours of power in minutes.

Reuse the state, verify the target, and capture

This complete example opens a fresh context from the saved state, checks that the target page is the expected signed-in view, and captures an image. It deliberately fails if the expected signed-in UI is absent, rather than silently saving a login redirect.

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const context = await browser.newContext({
    storageState: 'playwright/.auth/state.json'
  });
  const page = await context.newPage();

  await page.goto('https://example.com/account/reports', {
    waitUntil: 'domcontentloaded'
  });

  // Replace with a stable element that identifies the authenticated target view.
  await page.locator('[data-testid="reports-heading"]').waitFor({
    state: 'visible',
    timeout: 15000
  });

  await page.screenshot({ path: 'page.png', fullPage: true });

  await context.close();
  await browser.close();
})();

The selectors are site-specific examples, not universal login indicators. Prefer an element unique to the target view or an account UI that only appears when authenticated. Playwright’s screenshot API also supports format and path settings, scale, clipping, masking, and animation controls; see Page screenshot documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Samsung Galaxy A17 5G Smart Phone 128GB, US 1 Yr Manufacturer Warranty Blue
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Choose what the screenshot should contain

Viewport, full page, or clipped region

  • await page.screenshot({ path: 'page.png' }) saves the current viewport.
  • await page.screenshot({ path: 'page.png', fullPage: true }) captures the full scrollable page. A long page can create a very tall image.
  • Use clip when only a defined rectangle is needed, for example { x: 0, y: 0, width: 900, height: 600 } in CSS pixels.

Format and scale

Use a filename extension such as .png, .jpeg, or .jpg and set type: 'jpeg' if you want JPEG output. CSS scale produces one image pixel per CSS pixel; device scale uses the device-pixel ratio and can produce a larger, denser image. Select the scale based on the downstream need for crispness versus file size.

Animations and private regions

For a stable capture, disable animations with the screenshot animation option; this changes animation behavior during capture, so it may not reproduce a particular live animation frame. A locator mask can cover matching elements in the screenshot, which is useful for visible private data. Masking only affects the image: it does not sanitize the browser state, page, or other saved artifacts.

Rank #4
Sale
Samsung Galaxy S26 Ultra, Unlocked Android Smartphone, 512GB, Black
  • PRIVACY DISPLAY: Automatically hide your screen from those beside you. The built-in privacy display can be preset¹ to turn on when receiving notifications, typing passwords, or using specific apps
  • TYPE IT IN. TRANSFORM IT FAST: Enhance any shot in seconds on your smartphone by using Photo Assist² with Galaxy AI.³ Add objects, restore details, or apply new styles by simply typing or tapping
  • NIGHTS, CAPTURED CLEARLY: From gigs to city lights, record and capture moments after dark with clarity using Nightography so your photos and videos stay crisp and clear on your Samsung Galaxy
  • MAKE IT. EDIT IT. SHARE IT: Turn everyday moments into something personal with creative tools built right into your mobile phone, whether it’s a special contact photo, custom wallpaper, an invitation or more⁴
  • HELP THAT KEEPS UP: Stay in the moment while Now Nudge with Galaxy AI helps you respond faster and stay organized with smart suggestions⁵ that appear exactly when you need them on your phone

Give an AI agent a safe, verifiable task

Keep authentication separate from the agent’s instructions where possible. The agent can be asked to open a target URL using an already authorized context, confirm a named page element, and save a specified screenshot, without being given raw passwords or asked to extract cookies. The workflow should treat a failed verification as failure, not as a successful capture.

  • Use an account and target page you are authorized to access.
  • Limit the context and saved-state file to the task; do not commit state files or place them in shared folders.
  • Check the final image for login redirects, incomplete loading, or unintended private information.
  • Protect the screenshot itself: it may contain private page content even when credentials remain separate.

Playwright documents browser automation and capture behavior, not a universal policy for AI-agent authorization or every site’s terms. Follow the site’s access requirements and your organization’s handling rules.

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.
Best Value
Tracfone Moto g Play 2024 Prepaid Phone with a 1-Yr Plan Included
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Activating is easy, just 3 steps.
  • ACTIVATION Promotion: Includes 1500 min, 1500 texts & 1500 MB Data + add more as you need it
  • CAMERA SYSTEM: 50MP Quad Pixel camera. Capture sharper, more vibrant photos day or night with 4x the light sensitivity.
  • PERFORMANCE: Blazing-fast Qualcomm performance. Get the speed you need for great entertainment with a Snapdragon 680 processor and 4GB of RAM.
  • 64GB built-in storage. Get plenty of room for photos, movies, songs, and apps. Made for US
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot authentication and capture failures

Symptom Likely cause What to do
The target URL shows a login page The state was not saved after sign-in, has expired, or the site uses an authentication mechanism not restored by the standard state file. Repeat sign-in and save state only after a reliable signed-in signal. Check whether the site uses session storage or another mechanism; standard Playwright state does not persist session storage.
The login page appears intermittently The capture began before redirects or authentication setup completed. Wait for the expected authenticated UI or target-specific element rather than relying on a short fixed sleep.
The wait for a selector times out The selector is wrong, the page differs from the expected view, or the user is not authenticated. Inspect the rendered page and use a stable selector that actually appears on the intended page; do not remove the verification check merely to force a screenshot.
The screenshot is cut off The default capture covers only the viewport. Use fullPage: true for scrollable content or clip for a deliberate region.
The image is unexpectedly large or blurry Capture scale or page dimensions do not suit the output use. Choose CSS or device scale deliberately and consider capturing a defined clip instead of a very long page.
A private value remains visible The element was not covered by the chosen mask, or the data appears elsewhere in the image. Adjust the locator mask and inspect the complete output. Remember that masking does not protect the auth-state file or other browser artifacts.

Or skip the browser setup

If you want an API rather than managing a Playwright browser, ScreenshotNeo is a website screenshot API and MCP server. A standard screenshot request is one GET call (see the ScreenshotNeo API documentation):

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 and authorization inputs for capture workflows, but this call alone does not establish your authenticated session: supply the appropriate authorized authentication parameters for the target as described in the API documentation. Its cleanup can accept cookie/consent banners and remove known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks/CAPTCHAs, blank pages, failed loads, and cache hits are not billed, 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 screenshots.

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

Frequently Asked Questions

Does a Playwright storage-state file save every kind of login session?

No. Standard storage state does not persist session storage, and a site may use an authentication mechanism beyond cookies. Check the site’s authentication model if restoring state does not sign in.

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.

Can I capture only part of a signed-in page?

Yes. Use the screenshot API’s clip option for a defined rectangle, or a locator screenshot when the desired output is a particular element.

Quick Recap

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.