Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteUse one Playwright BrowserContext for login, navigation, and capture. Let the browser manage the app’s rotating session cookie; do not keep replaying a copied cookie value. For later runs, save and reload the context’s storage state, verify that the session is still accepted, then take the screenshot.
Why one browser context handles cookie rotation
A browser context owns its cookies and other browser state. When the app responds with a replacement session cookie, the browser processes it and uses the updated value on subsequent requests in that context. Keeping login, page navigation, and capture in the same context avoids manually copying a potentially stale cookie into each request.
As an Amazon Associate I earn from qualifying purchases.
Playwright also documents that API requests associated with a BrowserContext share its cookie storage and that response Set-Cookie headers update the context’s browser cookies. The app controls its own expiry and rotation policy, so a previously saved state file is only a snapshot—not a promise of a permanently valid login. See the BrowserContext API and API testing guide.
Log in, verify, and capture in one run
The following Node.js example uses the normal login form, waits for an authenticated-page marker, saves state for reuse, and captures the page. Replace the example URL, selectors, and credentials with values appropriate to your application. Install Playwright with npm install playwright and install its browser with npx playwright install chromium.
#1 Best Overall
- 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.
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext();
const page = await context.newPage();
try {
await page.goto('https://app.example.com/login', {
waitUntil: 'domcontentloaded',
});
await page.getByLabel('Email').fill(process.env.APP_EMAIL);
await page.getByLabel('Password').fill(process.env.APP_PASSWORD);
await page.getByRole('button', { name: 'Sign in' }).click();
// Wait for evidence of a completed, authenticated login.
await page.waitForURL('**/dashboard');
await page.getByRole('button', { name: 'Account' }).waitFor();
// Store cookies and supported browser storage for a later run.
await context.storageState({ path: 'playwright/.auth/user.json' });
// Navigate in the same context; any Set-Cookie rotation is handled by the browser.
await page.goto('https://app.example.com/dashboard', {
waitUntil: 'domcontentloaded',
});
await page.getByRole('button', { name: 'Account' }).waitFor();
await page.screenshot({ path: 'dashboard.png', fullPage: true });
} finally {
await browser.close();
}
})();
Use a final URL, visible account control, or another reliable signed-in marker as the success condition. A click completing is not proof that authentication completed: redirects may set cookies over several steps. Playwright’s authentication guide covers UI login and API-assisted authentication. Keep credentials in environment variables or a secret manager rather than committing them with the script.
Reuse saved authentication state on later runs
For repeated captures, authenticate once and initialize a new context from the saved state. Verify the signed-in UI after opening the target route. If the marker is missing or the app redirects to login, the snapshot has expired, been revoked, or does not include all state the app requires; perform the authorized login flow again and save a fresh snapshot.
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext({
storageState: 'playwright/.auth/user.json',
});
const page = await context.newPage();
try {
await page.goto('https://app.example.com/dashboard', {
waitUntil: 'domcontentloaded',
});
await page.getByRole('button', { name: 'Account' }).waitFor();
await page.screenshot({ path: 'dashboard.png' });
} finally {
await browser.close();
}
})();
Playwright’s standard storage state includes cookies and local storage. Some applications also depend on IndexedDB or session storage; check the authentication guide for the relevant save/restore approach. Session storage is not generally included in the usual storage-state file, so restoring cookies alone may not restore such an app’s session. State can also be browser- or application-specific.
Rank #2
- 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
Choose UI login or an authentication API
| Approach | When it fits | Trade-off |
|---|---|---|
| Log in through the UI | You need to reproduce the user journey, or the app establishes required state through its pages and redirects. | More steps to automate; wait for the final authenticated condition rather than assuming the sign-in click is enough. |
| Use an authentication API | The app provides a supported API that can authenticate a test account. | It can be quicker, but confirm it establishes all browser state required by the page. Use requests associated with the same context when relying on its shared cookie store. |
Playwright documents both UI-based and API-assisted setup in its authentication guide. Do not manufacture or hard-code a rotated cookie as a substitute for the app’s supported login flow.
Choose viewport or full-page capture
- Viewport: the default screenshot is the currently visible browser area. Use it when the evidence concerns the screen as a user currently sees it.
- Full page: set
fullPage: trueto capture the entire scrollable page. The resulting image can be much taller and may expose more account data.
Playwright’s Page API documents screenshot options, including locator masking. Mask sensitive regions when appropriate, and protect the resulting image according to the information it contains.
Protect authentication state and screenshots
- Keep the authentication directory out of source control. Playwright warns: “The browser state file may contain sensitive cookies and headers that could be used to impersonate you or your test account.”
- Limit access to saved state files and use a dedicated, minimally privileged test account.
- Do not assume saved state stays valid: expiry, revocation, and rotation behavior are controlled by the application.
- Cookie domain and path matter. Prefer letting the app establish cookies through login; when a test genuinely needs to add a cookie manually, follow Playwright’s requirements for a URL or both domain and path.
- Mask private content and securely store screenshots if the signed-in page displays sensitive information.
Troubleshooting
The page redirects to login after loading saved state
The snapshot may have expired or been revoked, or the app may require state not captured in the file. Repeat the authorized login flow, wait for the signed-in marker, save a fresh state, and check whether the app relies on session storage or other browser-specific state.
Rank #3
- 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
The script captures the login page instead of the app
Do not treat the button click as the completion signal. Wait for the expected post-login URL or an authenticated control, then check again after navigating to the capture route.
Free tools Windows power users keep installed
One-click scans. No signup required.
A cookie appears to rotate but requests stop authenticating
Keep requests in the same context and avoid manually replaying an old cookie value. Context-associated API requests share cookie storage and process response Set-Cookie updates. If the app rejects the session, log in again rather than inventing a replacement cookie.
Login works in the browser but not from the saved state
The app may depend on session storage, IndexedDB, or state established by a particular flow. Consult the Playwright authentication guide’s state handling details and add the app’s required supported state handling; do not assume a cookie-only snapshot is complete.
Rank #4
- 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.
The screenshot contains private data or misses content
Use Playwright’s screenshot masking support for sensitive regions. If content below the visible screen is required, enable fullPage: true; otherwise the default is a viewport capture. Review the image before sharing it.
Or skip the browser setup
If you need a screenshot API rather than managing a logged-in Playwright session, ScreenshotNeo takes a screenshot from one GET request. It removes cookie banners, popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed; and its MCP server lets AI agents take screenshots. It is not a way to authenticate into a private app: use an authorized browser session for pages that require login.
Recommended Free Tools
Example request for a publicly accessible page; see the ScreenshotNeo API documentation for parameters:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://app.example.com/dashboard -o shot.webp
The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo’s free plan.
Frequently Asked Questions
Does saving Playwright storage state preserve a rotating session cookie?
It saves a snapshot of browser state, including cookies and local storage; it does not guarantee that the app will continue accepting that snapshot after expiry, revocation, or rotation.
Can ScreenshotNeo take a screenshot of a page that requires my login?
The one-call example is for a publicly accessible page. For a page protected by your app’s login, use the authorized Playwright context flow described above.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →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.




