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

Use a dedicated persistent browser profile when automation must retain a complete signed-in browser between runs. Use Playwright’s saved authentication state instead when each test should start authenticated but run in an isolated context. Keep the profile or state file private, never point automation at your everyday Chrome data, and never launch two browsers with the same user-data directory.

Choose the persistence model first

“Browser profile reuse” can mean three different things in Playwright. The correct choice depends on whether you need a whole browser profile, only authenticated state, or no disk persistence at all.

Method What persists Isolation Concurrency and best fit
Persistent user-data directory Broad browser profile data, including cookies and local storage One persistent context owns the directory The directory cannot be opened by simultaneous browser instances; best for a continuing profile
Saved authentication state loaded into contexts Cookies, local storage, IndexedDB and passkey (WebAuthn) state; session storage requires separate handling Each test can create an isolated context with preloaded state Better for parallel or isolated tests; the state file is still a credential
In-memory session State only while the live browser session remains open Session-scoped Lost when the browser closes; useful when disk persistence is undesirable

These behaviors are documented in the Playwright BrowserType API, Authentication, MCP profile documentation, and CLI sessions documentation.

Use a dedicated persistent profile with Playwright

launchPersistentContext(userDataDir) starts a browser whose cookies, local storage and other profile data are written to the directory you provide. It returns the browser’s only context; closing that context closes the browser.

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.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.

1. Create a project and install Playwright

mkdir profile-automation
cd profile-automation
npm init -y
npm install -D playwright
npx playwright install chromium

2. Launch an automation-only directory

Do not use your normal Chrome “User Data” directory. Recent Chrome policy changes make automating the default profile unsupported, and Playwright warns that pages may fail to load or the browser may exit. Chromium’s user-data directory is the parent directory of the profile path displayed at chrome://version; do not pass only a profile subfolder when the API expects the containing user-data directory.

import { chromium } from 'playwright';

const context = await chromium.launchPersistentContext('./.pw-profile', {
  headless: false,
  viewport: { width: 1440, height: 900 }
});

const page = context.pages()[0] ?? await context.newPage();
await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
console.log(await page.title());
await context.close();

Run the script once with headless: false and complete the site’s normal sign-in flow. Later runs using the same ./.pw-profile directory can reuse the resulting cookies and local storage, subject to the site’s expiry, logout and security policies.

3. Make the first-run login explicit

import { chromium } from 'playwright';

const context = await chromium.launchPersistentContext('./.pw-profile', {
  headless: false
});
const page = context.pages()[0] ?? await context.newPage();
await page.goto('https://app.example.test/login');

if (await page.locator('input[name="password"]').count()) {
  console.log('Complete login in the opened browser, then press Enter here.');
  process.stdin.resume();
  await new Promise(resolve => process.stdin.once('data', resolve));
}

await page.goto('https://app.example.test/dashboard');
console.log('Dashboard URL:', page.url());
await context.close();

Prefer a test account and the site’s supported authentication flow. Reusing a profile is not a way to bypass a CAPTCHA, bot check, access control or a site’s terms.

4. Reopen the same profile on later runs

import { chromium } from 'playwright';

const context = await chromium.launchPersistentContext('./.pw-profile', {
  headless: true
});
const page = context.pages()[0] ?? await context.newPage();
await page.goto('https://app.example.test/dashboard', { waitUntil: 'networkidle' });
console.log('Signed-in page:', await page.title());
await page.screenshot({ path: 'dashboard.png', fullPage: true });
await context.close();

Use networkidle only when it is appropriate for the application; pages with analytics or long-polling requests may never become idle. A targeted locator wait is usually more deterministic.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.

Save authenticated state for isolated tests

A persistent directory gives you a continuing browser, but it couples runs to one profile. Playwright’s storage-state workflow lets you sign in once, save reusable state, and load that state into fresh contexts. The built-in state covers cookies, local storage, IndexedDB and passkey-based authentication. Session storage is not included; if your application requires it, use a separate custom save/load mechanism as described in the authentication documentation.

1. Generate an authenticated state file

import { chromium } from 'playwright';

const browser = await chromium.launch({ headless: false });
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://app.example.test/login');
console.log('Finish signing in, then press Enter.');
process.stdin.resume();
await new Promise(resolve => process.stdin.once('data', resolve));
await context.storageState({ path: '.auth/user.json' });
await browser.close();

Create .auth locally and add it to .gitignore:

.auth/
.pw-profile/

2. Load the state into a new context

import { chromium } from 'playwright';

const browser = await chromium.launch();
const context = await browser.newContext({ storageState: '.auth/user.json' });
const page = await context.newPage();
await page.goto('https://app.example.test/dashboard');
console.log(await page.title());
await browser.close();

Each worker can create its own context from the same state, avoiding the single-directory lock that applies to persistent profiles. The state file itself can impersonate the account, so restrict filesystem access, never commit it, never attach it to a bug report and delete or rotate it when it is no longer needed.

Prevent profile collisions in parallel work

Browsers do not allow multiple instances to use the same user-data directory simultaneously. A second process may report that the profile is locked, fail to launch or connect to the wrong running instance. Playwright MCP likewise documents one persistent profile per browser at a time.

  • Give every parallel worker a unique directory, such as .profiles/worker-1 and .profiles/worker-2.
  • Alternatively, use one read-only seed state file and create isolated contexts with storageState.
  • Close the context in a finally block so crashes do not leave avoidable locks.
  • Do not run a normal Chrome session against the automation directory while tests are active.
import { chromium } from 'playwright';

const worker = process.env.WORKER_INDEX ?? '0';
const context = await chromium.launchPersistentContext(`.profiles/worker-${worker}`, {
  headless: true
});
try {
  const page = context.pages()[0] ?? await context.newPage();
  await page.goto('https://app.example.test');
} finally {
  await context.close();
}

Understand what is and is not saved

Cookies and web storage

Persistent contexts retain browser profile data such as cookies and local storage. Storage-state files retain the documented authentication data, but application state held only in session storage needs a separate mechanism.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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.

Passkeys and device-bound authentication

Playwright’s authentication state supports passkey (WebAuthn)-based authentication. A site may still require a fresh challenge, device approval or reauthentication after its own security policy expires a session.

Service workers, caches and extensions

Do not assume every browser artifact is portable between machines or versions. Keep the automation browser and dependencies consistent, and design tests to detect a redirect to login rather than silently continuing with an unauthenticated page.

Security rules for reusable profiles

  • Use a dedicated test account with the minimum permissions needed.
  • Store profile directories and state files outside source control and with restrictive operating-system permissions.
  • Never publish them in screenshots, CI artifacts, support bundles or public logs.
  • Rotate credentials and revoke sessions if a profile artifact may have been exposed.
  • Delete stale profiles when a test environment is retired.
  • Do not treat a profile directory as a portable credential backup.

Playwright CLI and MCP profile behavior

Playwright CLI’s ordinary session profile is in memory unless disk persistence is enabled with its --persistent option. In-memory data survives commands within that live session but disappears when the browser closes. Playwright MCP offers persistent and isolated modes; its documented profile location is derived from the platform and workspace, and one profile can be used by only one browser at a time. Check the current configuration for the specific CLI or MCP version you deploy rather than assuming its defaults match Node.js Playwright.

Troubleshooting profile reuse

“The browser exits immediately” or pages do not load

Cause: automation is pointing at the everyday Chrome user-data directory or an unsupported default profile. Fix: create a new directory such as .pw-profile and launch it with launchPersistentContext.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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

“Profile is already in use”

Cause: another browser instance owns the directory. Fix: close the other instance, wait for its process to exit, or assign each worker a unique directory. Do not delete lock files while a browser is still running.

The test is redirected to login

Cause: cookies expired, the account was logged out, the origin changed, or the state file was generated before the login completed. Fix: regenerate state, verify the target origin, and add an assertion for a signed-in element before performing test actions.

Parallel tests change one another’s data

Cause: workers share a persistent context or account. Fix: use isolated contexts and test data, separate worker profiles, or separate test accounts.

State works locally but not in CI

Cause: the state file was not securely provided to CI, the browser version differs, or environment-specific cookies and URLs are being used. Fix: inject the state through a protected secret or workspace file, keep browser versions reproducible, and generate state inside the same environment when practical.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 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.

Session-storage-dependent code fails

Cause: session storage is not persisted by the built-in storage-state API. Fix: implement the documented custom save/load approach or change the application flow so the required state is represented by supported authentication storage.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability and cost decisions

  • Startup: a persistent profile avoids repeating login, but a large profile can increase startup and cleanup time. Keep it dedicated and periodically recreate it.
  • Parallelism: isolated contexts scale better than one locked persistent directory.
  • Reliability: wait for stable, application-specific locators and verify authentication before destructive actions.
  • Reproducibility: saved state is convenient but can hide expired credentials; regenerate it deliberately in setup jobs.
  • Privacy: in-memory sessions leave no profile on disk after shutdown, while persistent profiles and state files require explicit retention and deletion policies.

Or skip the browser setup

If your goal is a clean image or PDF of a URL rather than an interactive test session, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns PNG, JPEG, WebP or PDF. It accepts consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP tools—take_screenshot, get_page_info and capture_pdf—work with Claude, Cursor and other MCP clients.

See the complete parameter reference in the ScreenshotNeo documentation. A cURL request:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo includes full-page and element capture, device presets, custom viewports, retina scale, PDF controls, custom CSS and JavaScript, clicks, waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, selectable cache TTLs, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification. Its parameter names are compatible with those used by other screenshot APIs, easing migration. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots, and every feature is available on every plan. Create a free ScreenshotNeo account to start.

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

Frequently Asked Questions

Can I use my normal Chrome profile for Playwright automation?

No. Use a separate automation user-data directory; Playwright warns that automating Chrome’s default profile is unsupported and may cause load failures or browser exit.

Should I choose a persistent profile or storageState?

Choose a persistent profile for a continuing full browser profile. Choose storageState when tests should start authenticated but run in isolated contexts or parallel workers.

Why did my saved login stop working?

The site may have expired or revoked its cookies, required reauthentication, or changed its origin. Regenerate the state and assert that a signed-in element is present before test actions.

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.

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