Use Playwright’s launchPersistentContext(userDataDir) when browser state must remain on disk between runs, and give that profile directory exclusive use by one browser at a time. For most test suites, save authentication with storageState and create isolated contexts instead. Do not use Chrome’s everyday default profile for automation, and remember that Playwright’s built-in storage-state export does not include sessionStorage.
Choose a persistent profile or saved authentication state
These approaches both help automation retain login state, but they preserve and reuse state differently. A persistent profile is a browser profile directory used directly by a launched browser. A saved authentication state is a snapshot used to initialize new contexts.
As an Amazon Associate I earn from qualifying purchases.
| Approach | Best for | Trade-off |
|---|---|---|
launchPersistentContext(userDataDir) |
Automation that needs a browser profile to remain on disk across browser restarts. | The directory is in use by one browser instance at a time; concurrent instances must not share it. |
storageState |
Seeding new test contexts with intentionally saved authentication state. | It does not automatically preserve sessionStorage; apps depending on it need custom save-and-restore logic. |
Playwright’s BrowserType documentation describes persistent contexts and the user-data-directory restriction. Its authentication guide covers saving and reusing authentication state.
Persist a dedicated profile across browser runs
launchPersistentContext(userDataDir) launches a browser using the specified user-data directory and returns its only browser context. Closing that context closes the browser. Use a separate directory for automation rather than Chrome’s normal User Data directory: Playwright warns that automation of Chrome’s default profile is unsupported following recent Chrome policy changes.
#1 Best Overall
- MADE FOR THE MAKERS: Create; Explore; Store; The T7 Portable SSD delivers fast speeds and durable features to back up any endeavor; Build your video editing empire, file your photographs or back up your blogs all in an instant
- SHARE IDEAS IN A FLASH: Don’t waste a second waiting and spend more time doing; The T7 is embedded with PCIe NVMe technology that brings fast read and write speeds up to 1,050/1,000 MB/s¹, making it almost twice as fast as the T5
- ALWAYS MAKE THE SAVE: Compact design with massive capacity; With capacities up to 4TB, save exactly what you need to your drive – from large working files to game data and everything in between
- ADAPTS TO EVERY NEED: Whether using a PC or mobile phone, count on the T7 for extensive compatibility²; It’s a true team player when it comes to heavy-duty application usage or file-saving
- HI RESOLUTION VIDEO RECORDING: Record Ultra High Resolution (4K 60fs) videos directly onto the T7 Portable SSD with your favorite camera or mobile devices; Supports iPhone 15 Pro Res 4K at 60fps video and more³
import { chromium } from 'playwright';
const context = await chromium.launchPersistentContext('./playwright-profile', {
headless: false,
});
try {
const page = context.pages()[0] ?? await context.newPage();
await page.goto('https://example.com');
// Perform automation. The browser's profile state is stored in ./playwright-profile.
} finally {
await context.close();
}
Install Playwright in your project and run this script with your project’s JavaScript runtime. On later runs, launch against the same dedicated directory to reuse its profile state. Keep the context open for the work, then close it to release the browser and the directory.
Keep the profile exclusive
Do not start another browser instance against the same directory while the first is running. Playwright states: “Note that browsers do not allow launching multiple instances with the same User Data Directory.” A profile lock or launch failure commonly indicates that another browser still has the directory open. Close that process before retrying, or use a different directory for the other run.
Use saved authentication state for isolated tests
When each test should start with a fresh browser context, authenticate once, save Playwright’s storage state, then use that state to initialize contexts. This keeps authentication setup explicit without making simultaneous tests mutate the same live profile directory.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #2
- Get NVMe solid state performance with up to 1050MB/s read and 1000MB/s write speeds in a portable, high-capacity drive(1) (Based on internal testing; performance may be lower depending on host device & other factors. 1MB=1,000,000 bytes.)
- Up to 3-meter drop protection and IP65 water and dust resistance mean this tough drive can take a beating(3) (Previously rated for 2-meter drop protection and IP55 rating. Now qualified for the higher, stated specs.)
- Use the handy carabiner loop to secure it to your belt loop or backpack for extra peace of mind.
- Help keep private content private with the included password protection featuring 256‐bit AES hardware encryption.(3)
- Easily manage files and automatically free up space with the SanDisk Memory Zone app.(5). Non-Operating Temperature -20°C to 85°C
import { chromium } from 'playwright';
// Run once after signing in, or when the saved login expires.
const browser = await chromium.launch();
const setupContext = await browser.newContext();
const page = await setupContext.newPage();
await page.goto('https://example.com/login');
// Complete the application's sign-in flow here.
await page.context().storageState({ path: 'playwright/.auth/state.json' });
await setupContext.close();
// In a test or worker, create a separate context from the saved state.
const testContext = await browser.newContext({
storageState: 'playwright/.auth/state.json',
});
const testPage = await testContext.newPage();
await testPage.goto('https://example.com');
// Run assertions or automation, then close the context.
await testContext.close();
await browser.close();
The example leaves the application-specific login steps for your site. Store the state file somewhere private and make sure your test setup refreshes it when authentication expires. Playwright’s authentication guide documents the save-and-reuse workflow.
Account for sessionStorage
Playwright does not provide a built-in API to persist sessionStorage through storageState. If the application keeps required login state there, add explicit code to capture and restore the relevant values, or choose a persistent profile when preserving the broader browser profile is appropriate. Do not assume that a successful storage-state export recreates every part of a live session.
Make parallel runs reliable
Persistence does not make shared mutable state safe. A persistent directory is exclusive to one browser instance at a time; separate test workers should not launch against one shared directory. For a test suite, prefer independent contexts or state per test or worker, sharing only deliberately prepared authentication state. Playwright’s Best Practices recommends isolating storage and cookies to improve reproducibility and prevent cascading failures.
Rank #3
- Plug-and-play expandability
- SuperSpeed USB 3.2 Gen 1 (5Gbps)
- For a single automation process that must retain a whole profile between runs, use one dedicated persistent directory.
- For concurrent tests, create independent contexts and seed them from saved authentication state when suitable.
- If workers need different accounts or mutable application data, prepare separate state files or sign-in flows rather than having them share one changing state.
Protect profile and authentication files
Persistent profiles and saved authentication state contain login-related data and should be treated as sensitive credentials. Keep them out of public repositories, restrict file access, and avoid copying a personal browser profile into automation. A 2025 paper, “User Profiles: The Achilles’ Heel of Web Browsers”, examines the security sensitivity of on-disk browser profiles; do not treat a profile directory as harmless test data.
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 minuteTroubleshoot common persistence failures
Chrome exits or fails to launch with your regular profile
Use a separate, dedicated automation directory instead of Chrome’s everyday User Data directory. Playwright warns that use of Chrome’s default profile for automation is unsupported under recent Chrome policy changes. See the BrowserType API documentation.
Launch reports a profile lock or cannot open the directory
Check for another browser process already using that user-data directory. Close it before relaunching, or give the second process its own directory; simultaneous browser instances cannot use the same directory.
Rank #4
- Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
Tests interfere with each other or become flaky
Stop sharing one mutable profile across workers. Use separate contexts or per-worker state, and isolate cookies and storage as recommended in Playwright’s Best Practices.
Authentication disappears after saving storage state
Check whether the application depends on sessionStorage. Playwright’s built-in storageState API does not automatically persist it, so add explicit handling for the values the application needs or use a persistent profile where that is the right fit.
Or skip the browser setup
If your goal is a clean screenshot rather than authenticated browser automation, ScreenshotNeo is a website screenshot API and MCP server for developers. Its screenshot endpoint can return an image or PDF from one GET request. See the API documentation.
Best Value
- NEARLY 2X FASTER THAN OUR PREVIOUS GENERATION(8) – move 1,000 high-res photos in under 60 seconds(6) with up to 2000MB/s transfer speeds(2).
- IP65 RATING AND UP TO 3M DROP PROTECTION(3) – protects against spills and drops.
- POCKET-SIZED – fits easily in pockets and small bags.
- SPACE TO OWN YOUR AI CONTENT – speed and capacity to download your high-res clips and photo edits.
- 256-BIT AES ENCRYPTION(4) – helps keep private files secure with password protection.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
ScreenshotNeo accepts cookie or consent banners 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, with response headers indicating the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.
Frequently Asked Questions
Does Playwright save sessionStorage in storageState?
No. The built-in storage-state API does not automatically persist sessionStorage; save and restore the values explicitly if your application depends on them.
Can two Playwright workers use one persistent profile directory?
Not simultaneously. Use separate directories or independent contexts with intentionally shared authentication state.
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.




