Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC 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 & 11To avoid logging in through the UI before every Playwright test, authenticate in a setup project, save the resulting browser state, and load it with storageState in the tests that need it. Use one shared account only when tests can safely run against the same server-side data; for tests that change shared data, use a separate account and saved state for each worker.
Choose an authentication strategy that fits your tests
The key decision is whether tests can safely share an account. Reusing one login state reduces setup work, but it does not isolate server-side data. If parallel tests can change the same account’s data, account collisions can cause flaky results even when each browser context has its own cookies.
As an Amazon Associate I earn from qualifying purchases.
| Test situation | Recommended approach | Why |
|---|---|---|
| Tests are independent and do not interfere through shared account data | Authenticate once in a setup project and reuse its saved state | Avoids repeating the login flow for each test. |
| Tests mutate shared server-side data | Use a distinct account and saved state per parallel worker | Reduces interference between concurrent tests. |
| The app provides a suitable, simpler or faster authentication API | Authenticate through the API and save its storage state | Skips UI login setup while keeping the tested features covered by browser E2E tests. |
Playwright Test runs tests in worker processes. By default, test files can run in parallel, while tests in one file run in order in the same worker. Separate parallel tests do not share browser state or global variables, but they can still affect the same server-side account data. See Playwright TestConfig and Playwright Test.
Recommended Free Tools
Reuse one account with a setup project
For independent tests, use a setup project to sign in once and save the resulting state. Make the browser projects depend on setup and configure them to load the saved file with storageState. Playwright’s authentication guide shows this pattern with Chromium and Firefox projects: Authentication.
#1 Best Overall
Do not save state merely because the login button was clicked. Wait until the application has completed authentication—for example, until the expected final URL appears or a stable signed-in UI element is visible. This matters when cookies are established during a redirect; saving too early can produce a state file that looks valid but is not authenticated.
Project dependencies run before the projects that depend on them. After setup succeeds, dependent browser projects can run in parallel, subject to the configured worker limit. If setup fails, dependent projects do not run. Details are in Playwright projects.
Rank #2
Use a separate account for each worker when tests mutate data
If tests create, edit, or delete shared server-side records, a single account can make parallel tests race against one another. Playwright recommends one account per parallel worker for this case. The documented pattern overrides the storageState fixture with a worker-scoped fixture, uses test.info().parallelIndex to identify the worker, authenticates in a clean context, saves a worker-specific state file, and reuses it for that worker’s tests. See Playwright authentication.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Worker-specific accounts protect tests running within one run, but concurrent local and CI runs also need distinct accounts. Otherwise, two independent runs may still modify the same account’s data. Provision accounts or allocate them so simultaneous runs cannot collide.
Authenticate through an API when the app supports it
If the application offers an authentication API that is simpler or faster than its UI login flow, use an API request context to authenticate and save the resulting storage state. Browser tests can then load that state and exercise authenticated features without repeating the login UI. This approach depends on the application’s supported authentication flow; there is no universal endpoint or exchange to assume. The official pattern is documented in Playwright’s authentication guide.
Choose project dependencies or globalSetup
For most authentication setup, project dependencies integrate the work into Playwright Test’s normal runner lifecycle. They can use fixtures and browser management, and setup appears in the HTML report and can produce traces. Playwright recommends this approach for global setup actions. See Global setup and teardown.
globalSetup is still available and can authenticate once, write a state file, and pass data to tests. The trade-off is that it does not provide the same project-dependency features, including setup visibility in reports, traces, fixtures, and standard setup parallelism and retry behavior. Use it when its simpler lifecycle fits your needs rather than expecting those runner integrations.
Handle roles, browser state, and expiration
Different roles across tests
When tests use different roles and each role can reuse an account, create a state file per role and select the appropriate file with test.use({ storageState: ... }) for the relevant file or describe block. If a single test needs two signed-in roles at once, create two browser contexts with their respective states, use a separate page in each, and close both contexts when done.
Know what saved state includes
Playwright’s standard saved state covers cookies, local storage, IndexedDB, and passkey (WebAuthn)-based authentication. It does not persist sessionStorage. If the app relies on session storage, the authentication guide demonstrates saving it separately and injecting it with an init script for the target hostname: Authentication.
Protect and refresh state files
Saved browser state may contain cookies and headers that allow someone to impersonate a test account. Playwright recommends creating a playwright/.auth directory and adding it to .gitignore. Never commit state files. Delete or regenerate state when authentication expires. If the file only needs to exist for one run, save it under testProject.outputDir, which Playwright cleans before each run.
UI mode does not run the setup project by default, to improve speed. When stored credentials have expired, run the authentication setup manually as described in the authentication guide.
Quick Recap
Implementation checklist
- Decide whether concurrent tests can safely share account data. Use one account for independent tests; isolate accounts for tests that mutate shared data.
- Choose UI or API authentication. Use an API flow only if the application supports one that produces suitable browser state.
- Authenticate in a setup project, or create worker-scoped authentication when each worker needs its own account.
- Wait for a final redirect or stable signed-in UI condition before saving state.
- Configure relevant browser projects or tests to load the state with
storageState. - Use a separate state file per reusable role, or separate contexts when a test needs multiple roles simultaneously.
- Keep state files out of source control, account for expiration, and handle
sessionStorageseparately if the app uses it. - Use project dependencies when setup should participate in reports, traces, fixtures, and normal runner behavior; choose
globalSetuponly when its simpler lifecycle is a better fit.
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.




