To screenshot a page behind a login, open it in a browser context that is already authenticated, verify that the protected content loaded, and then capture the viewport, full page, or a specific element. A URL alone does not carry login state. With Playwright, you can complete the site’s login flow once and reuse saved browser state for later captures; protect that state as carefully as a password because it can grant account access.
Choose an authentication workflow
There are two practical approaches. Log in through the browser for a one-off capture or whenever the site requires an interactive flow such as multi-factor authentication. For repeat runs, save authenticated browser state and load it into a new context. Which works depends on the target site’s login, verification, and session policies.
| Workflow | Best fit | Trade-off |
|---|---|---|
| Log in for each capture | One-off screenshots, or sites whose login and MFA flow must be completed interactively | Repeats the login flow and may take longer; the automation must handle redirects and verification |
| Save and reuse browser state | Repeated screenshots or automated test runs | The state is sensitive, can expire, and may not include session storage automatically |
Do not assume that a manually copied cookie or token will be enough. A site may require additional factors or bind sessions to a browser or device. The site’s own documentation or administrator is the authority on its authentication rules.
Set up Playwright
The examples below use Node.js and Playwright. Install Playwright and its Chromium browser in your project:
#1 Best Overall
- 【1080P HD High Quality】Capture resolution up to 1080p for video source and it is ideal for all HDMI devices such as PS4, PS3, Xbox One, Xbox 360, Wii U, DVDs, DSLR, Camera, Security Camera and set top box. Note: Video input supports 4K30/60Hz and 1080p120/144Hz. Does not support 4K120Hz/144Hz. Output supports up to 2K30Hz.
- 【Plug and Play】No driver or external power supply required, true PnP. Once plugged in, the device is identified automatically as a webcam. Detect input and adjust output automatically. Won't occupy CPU, optional audio capture. No freeze with correct setting.
- 【Compatible with Multiple Systems】suitable for Windows and Mac OS. High speed USB 3.0 technology and superior low latency technology makes it easier for you to transmit live streaming to Twitch, Youtube, Facebook, Twitter, OBS, Potplayer and VLC.
- 【HDMI LOOP-OUT】Based on the high-speed USB 3.0 technology, it can capture one single channel HD HDMI video signal. There is no delay when you are playing game live.
- 【Support Mic-in for Commentary】Rybozen capture card has microphone input and you can use it to add external commentary when playing a game. Please note: it only accepts 3.5mm TRS standard microphone headset.
npm init -y
npm install -D playwright
npx playwright install chromium
Use a dedicated test account where possible. Do not put passwords, tokens, or saved browser state in source control. Playwright’s authentication guide explains storage-state reuse and warns that saved state may contain cookies and headers capable of impersonating the account: Playwright authentication.
Log in, verify access, and save state
For the first run, use the site’s normal login page rather than trying to inject a credential into the target URL. Replace the example URLs and selectors with those for your site. The example waits for the protected page’s URL and a page-specific element before saving state; a successful click or navigation request by itself does not prove the right account content appeared.
// save-auth.js
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://example.com/login');
await page.getByLabel('Email').fill(process.env.SITE_EMAIL);
await page.getByLabel('Password').fill(process.env.SITE_PASSWORD);
await page.getByRole('button', { name: 'Sign in' }).click();
// Adapt these checks to the site. Complete any required MFA or redirects first.
await page.waitForURL('**/dashboard');
await page.getByRole('heading', { name: 'Account dashboard' }).waitFor();
await context.storageState({ path: 'private/auth-state.json', indexedDB: true });
await browser.close();
})();
Recent Playwright versions support saving IndexedDB as part of storage state; check the current authentication documentation if your installed version does not accept that option. Keep the output directory private and ignored by version control. Storage state can preserve cookies, local storage, IndexedDB, and passkey-based authentication. Session storage is the important exception: Playwright does not automatically persist it through the standard storage-state flow.
When the site uses session storage
If the application keeps required auth data in session storage, the normal state file may not recreate the logged-in session. Playwright’s authentication guide demonstrates saving session storage separately and restoring it with an initialization script. Use that method only for a site you are authorized to access, and protect the extracted value as a credential. Do not log it or place it in a committed fixture.
Rank #2
- 【1080P 60FPS Video Capture Card】 This HDMI game capture card is based on USB3.0 high speed transmission port, input resolution up to 4K@30HZ, output resolution up to 2K@30Hz or 1920×1080@60Hz. Type c and USB interface can meet most of the devices in daily life. Easily meet the online capture, real-time recording, online meetings, live gaming and other functions, so you have a better visual enjoyment. Note: For capture use only; requires capture software to function and is not intended for direct screen casting to a monitor or TV
- 【Ultra Low Latency Screen Sharing】 HDMI capture card is made of good quality aluminum alloy with strong heat dissipation, allowing you to enjoy ultra low latency while live gaming or video recording or live streaming, avoiding blue screens and lag. This HDMI to USBC capture card supports easy recording of good quality audio or HD video and transferring it to your computer or streaming platform, allowing you to record 60 fps HD video directly on your hard drive and real-time preview
- 【Plug and Play, Easy to Carry】 This HDMI 1080P video capture card does not require any additional drivers or external power supply, just plug and play for fast capture. The capture card is small and lightweight, so you can put it in your bag for emergencies, making it very portable for outdoor live streaming. It's also a great way to share content in game recording, video conference, video recorder and online teaching
- 【Wide Compatibility USB Capture Card】 Easily streams to Facebook, Youtube or Twitch. With the connection, this HDMI to USB C/3.0 video capture devices can be working on several Operating Systems and various software: Windows 7/ 8/ 10, Mac OS or above, Linux, Android, Laptop, Xbox One, PS3/PS4/PS5, Camera, DVDs, Set Top Box, Webcame, DSLR, Switch/Switch 2, TV BOX, HDTV, Potplayer/VLC, ZOOM, OBS Studio etc.
- 【Package Content & Note】 1x HD Audio Capture Card , 1x USB 3.0 to USB C Adapter (A-side 3.0, B-side 2.0), 1x user manual. Please note that you need to restart the OBS Studio software after the audio setup is complete, otherwise it will result in no sound output. When using an adapter, if the device is recognized as USB 2.0, try using the other side with the USB-C port. Simply flip the capture card and reconnect it to be recognized as USB 3.0
Reuse state and capture the protected page
Load the saved state into a fresh browser context, navigate to the protected route, verify the intended page, then choose a screenshot scope. The path must be readable by the process; ensure its parent directory exists before running the save script.
// capture.js
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext({
storageState: 'private/auth-state.json',
});
const page = await context.newPage();
await page.goto('https://example.com/account/reports', {
waitUntil: 'domcontentloaded',
});
await page.getByRole('heading', { name: 'Reports' }).waitFor();
// Viewport capture. Use fullPage: true for the whole scrollable document.
await page.screenshot({ path: 'report.png', fullPage: false });
await browser.close();
})();
Run the scripts with credentials supplied through environment variables, not literals in the file. For example, set SITE_EMAIL and SITE_PASSWORD in your shell or secret manager before running node save-auth.js, then run node capture.js. Use the environment-variable syntax appropriate to your operating system or shell.
Pick the right screenshot scope
- Viewport: captures what is visible in the browser window. This is useful when the evidence should show the page as presented at a particular screen size.
- Full page: set
fullPage: trueto capture the full scrollable document, including content below the fold. Lazy-loaded sections may need to be scrolled into view or otherwise loaded before capture. - Element: use a locator’s
screenshot()method when only one component matters, such as a report panel or invoice.
// Full page
await page.screenshot({ path: 'full-page.png', fullPage: true });
// One element, selected with a site-appropriate locator
await page.getByRole('region', { name: 'Monthly report' })
.screenshot({ path: 'report-panel.png' });
Playwright’s screenshot APIs also support image type and scale, masking, animation handling, and other capture options. See the official screenshots guide and Page API for the options available in your installed version.
Cookies, tokens, and browser state are not interchangeable
A cookie is one part of browser state, but web applications can keep authentication-related state in local storage, IndexedDB, passkey/WebAuthn credentials, or session storage. A bearer token copied from a request is not automatically a complete browser session: the app may need other state, or the server may reject the token outside its expected context.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Rank #3
- 4K60 Capture: Record in cinematic quality with crisp detail and vivid colors
- HFR Support: Play and capture in 1440p120 or 1080p240
- HDR10 Support: Capture brilliant HDR content with tone mapping on Windows
- Cross-Platform Compatible: Works with PS5, Xbox Series X/S, Switch 2, and more
- Analog Audio In: Capture in-game chat or commentary with 3.5mm input
Chrome DevTools can help inspect cookies for a session: open DevTools, choose Application → Storage → Cookies, then select the relevant origin. Its documentation covers viewing, adding, editing, and deleting cookies: Chrome DevTools cookie guide. Inspection is useful for diagnosis, but copying a session cookie creates a credential-handling risk and may not satisfy additional authentication checks.
Keep credentials and screenshots safe
- Treat cookie jars, storage-state JSON, and bearer tokens like passwords. Anyone with usable state may be able to act as that account.
- Use a dedicated, least-privilege account when possible; restrict file permissions and keep authentication files outside public or shared directories.
- Add state files to your ignore rules, never commit them, and remove temporary state when it is no longer needed. Avoid printing tokens or state contents in logs.
- Check screenshots for visible secrets, personal data, or account details before sharing them. Do not capture accounts or pages unless you are authorized.
Playwright explicitly warns that its browser state file may contain sensitive cookies and headers usable to impersonate a user or test account: Playwright’s state-file warning.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Make repeated captures dependable
Wait for a meaningful, page-specific signal before capture: a heading, report row, or other element that proves the authenticated content is present. If the page renders asynchronously, wait for the relevant selector or a condition your application exposes rather than relying on a fixed pause alone. Record the target URL and account/test fixture for each run so a redirect to a login or error page is not mistaken for a successful screenshot.
For visual comparisons, keep the browser version, operating system, viewport, settings, and headless mode consistent. Playwright’s screenshot assertion waits for two consecutive screenshots to match before comparing, but its visual comparison guidance notes that rendering can vary with host OS, browser version, settings, hardware, power source, and headless mode. See visual comparisons and PageAssertions.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsRank #4
- High-Quality Video Capture, 4K HDMI Capture Card Ready: Capture smooth and vibrant video with this 4K HDMI capture card, engineered for gamers and content creators who demand crisp 1080P 60FPS video quality. Whether you're streaming to Twitch or recording gameplay for YouTube, your footage will look professional and detailed
- Plug-and-Play USB Capture Card, No Drivers Needed: Designed as a USB capture card for streaming, this device works instantly out of the box, just plug into your PC or laptop and start capturing. Fully compatible with popular software like OBS Studio, Streamlabs, and XSplit, making setup quick and stress-free for beginners and pros alike
- Universal Compatibility PS5, Xbox, Switch & More: Stream or record gameplay from virtually any HDMI-enabled device including Nintendo Switch, PS5, Xbox Series X, DSLR cameras, and PCs. The video capture card for gaming supports seamless passthrough so you can play without lag while your audience watches every frame in real time
- Low-Latency Performance for Smooth Streaming: This capture card for streaming minimizes delay between gameplay and broadcast, so you get reliable, low-latency capture that works well for competitive gaming, live broadcasts, and podcast sessions. Suitable for those building their channel with high-quality, engaging content
- Compact & Portable Design for Content Creators: Lightweight and portable, this USB 3.0 capture card works well for creators who travel or switch gaming setups often. Throw it in your bag and stream or record wherever you are, at home, events, LAN parties, streaming or studio sessions
Troubleshoot common failures
- You land on the login page: the state may be expired, saved before login completed, or missing a required store. Repeat the normal login flow, wait for a verified authenticated page, and save state again.
- The page loads but shows the wrong account or no protected content: verify the account and route with an authenticated page element, not just the final HTTP navigation. Check that the expected state file is being loaded.
- Cookies appear present, but the site still rejects the session: authentication may depend on local storage, IndexedDB, session storage, passkeys, MFA, or browser/device context. Follow the site’s supported login process; cookie injection alone is not guaranteed to work.
- State works once and then fails: sessions can expire or be revoked. Reauthenticate and regenerate state instead of treating the file as permanent.
- The screenshot is blank, incomplete, or missing an element: confirm the page-specific locator exists before capture and that lazy content has loaded. Use full-page capture only after the document content is ready.
- Visual diffs fluctuate between runs: standardize browser and host conditions, viewport, and rendering mode; environment differences can change pixels even when the page content is the same.
- The screenshot contains private data: limit access to output files, redact or mask sensitive regions before distribution, and delete unneeded captures securely according to your organization’s practices.
Or skip the browser setup
For pages accessible to ScreenshotNeo, a single request can return a screenshot or PDF. ScreenshotNeo is a website screenshot API and MCP server from Yorker Media. Its clean-shot options accept consent banners as a visitor and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. It is not a way to authenticate to a protected account: the target still needs to be reachable under the access setup you are authorized to use.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for the request options and response details. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and whether the request was billed. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, or another MCP client. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo and get 1,000 free screenshots a month with no card.
Frequently Asked Questions
Can I put a login cookie or bearer token in the page URL?
No. A URL does not itself provide browser authentication state, and placing credentials in a URL can expose them. Use an authorized authenticated browser context and protect its state.
Does Playwright storage state save session storage?
No. Its standard storage-state workflow does not automatically persist session storage; the Playwright authentication guide documents a separate save-and-restore approach.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Can I use a copied cookie to access any logged-in page?
Not reliably. The site may require other browser state, extra verification, or a session bound to a browser or device.
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.




