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 minuteTo keep a Playwright test logged in, save the browser state your app actually uses and load it into a fresh test context. Use storageState for portable authentication snapshots; use a persistent browser profile only when you need the browser’s on-disk profile to survive a restart. For MFA tests, use dedicated test accounts and virtual WebAuthn credentials or test-only OTP seeds—do not disable production MFA or copy production credentials into fixtures.
What “keeping a browser logged in” means
A browser does not have one universal login switch. An application may keep authentication in cookies, localStorage, IndexedDB, origin-private data, sessionStorage, or passkeys (WebAuthn credentials). Some applications use more than one. A saved snapshot works only for the stores it captures, so first identify what the app uses after a successful login.
Playwright’s storageState is a portable snapshot for creating new contexts. It captures cookies and local storage, and can include IndexedDB when requested. It is not a copy of every part of a browser profile: in particular, sessionStorage requires separate handling. A persistent context instead uses a profile directory saved on disk, which is useful when the browser itself must retain state across launches.
| Approach | Survives browser restart? | Portable across workers or machines? | Best fit |
|---|---|---|---|
| In-memory context | No; state ends when the browser closes. | No. | Isolated tests that sign in for each run or load a state snapshot. |
storageState |
The saved file persists; a new context can load it. | Yes, if securely distributed to the worker that needs it. | Repeatable tests, parallel workers, and CI. |
| Persistent profile | Yes; the profile directory is stored on disk. | Not inherently; sharing a profile can cause conflicts and expose state. | Local debugging or workflows that specifically need a continuing browser profile. |
These choices solve different problems. A profile can also retain browser data beyond authentication, while a state snapshot is easier to reproduce and isolate. Neither makes an expired account session valid again.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Save authentication state with Playwright
1. Sign in once and write the snapshot
The following TypeScript example assumes your sign-in page has fields labeled “Email” and “Password” and a button named “Sign in.” Adapt those locators to your application, then set the environment variables before running it. For IndexedDB-backed authentication, use a Playwright release that supports the indexedDB storage-state option (introduced in v1.51).
import { chromium } from '@playwright/test';
import { mkdir } from 'node:fs/promises';
const appUrl = process.env.APP_URL;
const email = process.env.TEST_EMAIL;
const password = process.env.TEST_PASSWORD;
if (!appUrl || !email || !password) {
throw new Error('Set APP_URL, TEST_EMAIL, and TEST_PASSWORD');
}
await mkdir('playwright/.auth', { recursive: true });
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto(new URL('/login', appUrl).toString());
await page.getByLabel('Email').fill(email);
await page.getByLabel('Password').fill(password);
await page.getByRole('button', { name: 'Sign in' }).click();
await page.waitForURL(url => !url.pathname.endsWith('/login'));
await context.storageState({
path: 'playwright/.auth/user.json',
indexedDB: true,
});
await browser.close();
The URL wait is only a generic example: choose a success condition that is meaningful for your app, such as a known account page or authenticated UI element. If the application uses cookies or localStorage but not IndexedDB, you can omit indexedDB: true. If login requires MFA, complete the real test-account enrollment and verification flow in this setup step; do not silently skip the factor.
2. Load the state in tests
For a small suite, configure tests to use the snapshot directly:
import { test } from '@playwright/test';
test.use({ storageState: 'playwright/.auth/user.json' });
test('opens the account page while signed in', async ({ page }) => {
await page.goto('https://app.example.test/account');
await page.getByRole('heading', { name: 'Account' }).waitFor();
});
For a larger suite, put the login and state creation in a Playwright setup project, then make the browser tests depend on it. This avoids repeating sign-in when the suite starts while retaining a clear setup boundary. Keep separate state per test identity and, where sessions can interfere, per worker. Do not have parallel tests mutate a shared account’s settings or revoke each other’s session.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Choose a persistent profile only when the browser must persist
Use launchPersistentContext when a continuing on-disk browser profile is itself part of the workflow—for example, interactive local debugging. The user-data directory must be unique to the process, and the returned context is the persistent context:
import { chromium } from '@playwright/test';
const context = await chromium.launchPersistentContext('./.pw-profile', {
headless: false,
});
const page = await context.newPage();
await page.goto('https://app.example.test');
// Close the context to finish; the profile directory remains on disk.
await context.close();
Do not launch concurrent workers against the same profile directory. It is mutable browser state, not a clean fixture; tests can affect one another, and a profile may contain more than the credentials you intended to retain. For CI and parallel suites, snapshots loaded into isolated contexts are usually easier to control.
Handle sessionStorage separately
Playwright does not persist sessionStorage through storageState. It is origin-scoped, and applications may use it for temporary workflow data as well as authentication. Only serialize it if you have confirmed the app depends on it; restoring stale workflow keys can send tests into the wrong step or preserve invalid state.
After authenticating, capture only the relevant origin’s values and inject them before the application scripts run:
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
const origin = 'https://app.example.test';
const sessionEntries = await page.evaluate(() =>
Object.entries(sessionStorage)
);
await context.storageState({ path: 'playwright/.auth/user.json' });
await context.close();
const testContext = await browser.newContext({
storageState: 'playwright/.auth/user.json',
});
await testContext.addInitScript(({ savedOrigin, entries }) => {
if (location.origin === savedOrigin) {
for (const [key, value] of entries) {
sessionStorage.setItem(key, value);
}
}
}, { savedOrigin: origin, entries: sessionEntries });
Install the initialization script before creating or navigating the page that loads the application. Keep this data in the same protected location as the auth snapshot. If the test only needs a specific session key, save and restore that key rather than copying the entire store.
Automate MFA without weakening it
WebAuthn and passkeys
For automated WebAuthn tests, create a dedicated test account and enroll a virtual authenticator through the normal registration flow. Playwright can include virtual WebAuthn credentials in storage snapshots. The snapshot can contain private keys; restoring it installs a virtual authenticator in that context, and real authenticators do not work in that context. Keep the fixture isolated from production accounts. Microsoft Edge DevTools also offers a software virtual authenticator for registration and debugging.
WebAuthn/FIDO2 is the stronger option when phishing resistance matters: credentials are scoped to the legitimate origin rather than being reusable codes typed into an arbitrary page. The WebAuthn protocol uses a challenge and response, and authenticator operations require user consent. In automated tests, verify the normal enrollment, assertion, cancellation, and recovery paths rather than treating successful login alone as sufficient coverage.
TOTP and other one-time codes
For TOTP tests, put the seed in a secret manager accessible only to the test worker, and generate codes in the test environment at run time. Never log codes, place seeds in source control, or keep them in plaintext longer than the test requires. Use an isolated account and separate test seed; production credentials do not belong in test fixtures.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Validate the security behavior as well as the happy path. OWASP guidance calls for short OTP lifetimes, single use, strict attempt limits, and invalidation after successful verification. Test that a used code is rejected, expired codes fail, repeated guesses trigger rate limits or lockout as designed, and controls apply consistently across web, API, federated sign-in, and account-reset routes. Check that application logs do not contain OTP values or secrets.
Protect saved state like a credential
Authentication snapshots can contain cookies, headers, tokens, IndexedDB data, or private WebAuthn keys that enable account impersonation. Treat the files as secrets, not ordinary test artifacts.
- Add the auth-state directory and persistent profile directories to
.gitignore. - Restrict filesystem permissions to the test account or worker that needs access.
- Use encrypted storage for backups and CI artifacts; do not publish state files as build artifacts accessible to everyone.
- Keep one fixture per test identity and rotate or regenerate it after expiry, revocation, or suspected exposure.
- Use test-only accounts with minimal permissions, and avoid production data and production MFA seeds.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server, not a Playwright session-persistence mechanism. If your task is to capture a page rather than run authenticated browser tests or automate an MFA flow, one GET request returns an image or PDF. See the ScreenshotNeo site and API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
Its clean-shot options accept consent banners like a visitor and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, with the verdict and billing status reported in response headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf 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. Sign up for 1,000 free screenshots a month—no card required.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Troubleshoot authentication that does not carry over
- The new context lands on the login page: Confirm the snapshot was saved after a real successful login, uses the correct origin, and is loaded before navigation. The session may also have expired or been revoked; recreate the state rather than trying to revive an invalid token.
- Cookies appear present, but the app is signed out: Check whether the token is actually stored in localStorage, IndexedDB, or another store. Enable the IndexedDB snapshot option where applicable, and verify that the context uses the same scheme, hostname, and port as the saved state.
- The app works in one page but not a new tab: Determine whether it relies on sessionStorage, which is scoped to an origin and not included in the snapshot. Restore only necessary values with an initialization script before application code runs.
- Parallel tests randomly lose authentication: Give workers separate test identities or state files if the application invalidates sessions, rotates credentials, or shares mutable account state. Do not share a writable persistent profile.
- WebAuthn works only in the setup context: Save and restore the virtual credential through the controlled test fixture, and run assertions in the context with that virtual authenticator. A real authenticator will not operate in a context where the restored virtual authenticator is installed.
- OTP tests intermittently fail: Generate codes close to verification time, allow for the app’s configured clock window, and verify synchronized worker clocks. Do not “fix” timing failures by making production OTPs long-lived or reusable.
Performance, reliability, and cost choices
A one-time login setup plus state reuse reduces repeated authentication work, but saved sessions have a lifetime: applications can expire, rotate, or revoke them. Plan to recreate state when needed, and make the setup project report a clear failure if sign-in no longer succeeds. Keeping one identity per worker costs more test-account administration but avoids hidden cross-test coupling.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Persistent profiles avoid repeating some local browser setup but carry mutable disk state and are poor shared fixtures. Snapshot files are more portable and easier to pair with isolated contexts; they also need secret storage and refresh procedures. Choose based on what must persist, then test the expiry and regeneration path so a stale file does not make the whole suite fail mysteriously.
FAQ
Does an authentication snapshot preserve browser history or cache?
No. storageState is for authentication-related state stores that Playwright supports, not a complete browser-profile backup. Use a persistent profile only if the continued browser profile itself is required.
Should every test share one logged-in account?
Only when the tests are independent of mutable account state and concurrent sessions do not revoke or interfere with one another. Otherwise use distinct test identities or worker-scoped fixtures.
Can an automated MFA test use a production recovery code?
Do not put production recovery credentials into automation. Exercise recovery with a dedicated test account and controlled test-only credentials.
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.

