How do I run Playwright or Selenium tests in parallel without shared-state collisions?
Asked by The SDET Playbook
Asked Sep 28, 2026Viewed 0 times
How do I run Playwright or Selenium tests in parallel without shared-state collisions?
Asked by The SDET Playbook
Sign in to answer and to vote.
Parallel runs fail on shared state, not on the tool. Playwright runs test files in parallel by default, keeps tests in one file in order unless you configure parallel mode, and can shard a suite across machines. Its guidance is to make every test isolated with its own storage, cookies and data. If tests change server-side state, give each parallel worker its own account, using the worker's parallel index to choose one. Selenium scales through Grid or a test runner's parallel mode, and its practices pages likewise call for independent tests and a fresh browser per test.
To spread a large suite across CI machines, run one shard per job (for example npx playwright test --shard=1/4 on the first of four), give each worker its own generated account rather than a shared admin login, and point the run at an isolated environment or database schema. Merge the per-shard results into one report at the end, with Playwright's blob reporter and merge-reports or by combining JUnit XML, before you publish the build status.
Sources: Playwright best practices, Playwright authentication, Playwright sharding, Selenium docs