Isolation: browser contexts and a fresh state for every test
Playwright gives each test a fresh browser context. Learn what that isolates, what it does not, and how to act as two users in one test.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a clean hotel room for each guest. No bags and no keys are left from the last guest. Guests cannot see each other's things. The hotel building, though, is still one building.
Daily List is a to-do list app. Tom's rename test passes alone. In the full run it fails. The browser room was clean. Both tests had used the same account on the server.
What it is: Playwright is a library that drives a real browser. This slice is isolation. Each test gets a fresh , a separate profile like a private window. A is one operating-system process that runs tests. Test data isolation is the matching rule for the server: each test gets its own rows. The nearest neighbour is a shared browser profile, which is how a careless Selenium suite leaks cookies from test to test.
Why it matters: A test that passes alone and fails in the suite wastes a day. A fresh context stops one test's cookies from poisoning the next. It does not stop two tests from editing the same server row.
A hotel room is cleaned by staff. Playwright makes a new context quickly. The server data is still shared until the tests stop sharing it.
(SYNTHETIC / TRAINING ONLY: Daily List and every person named here are made up.)
PLAIN WORDS · 3 in this section
- rename
- give a new name to
- playwright
- a free Microsoft tool that drives a browser for tests
- selenium
- A free tool that drives a web browser for checks.
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Giving each test a clean browser, and remembering that the server is shared.
- Fresh context
- Unique data
- Clean up
- Repeat to check
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| A freshly cleaned room | A new browser context |
| The building around the rooms | The server and its data |
| A name tag no one else has | A unique task title |
| Two guests in two rooms | A multi-context test |
WHERE THIS PICTURE STOPS
- A hotel has staff who clean rooms, but Playwright makes a context new in a blink.
- A hotel is one building, but a server can have many kinds of shared data.
- Guests do not share keys, but two pages in one context do share cookies.
HOOK
Clean room, shared building.
REMEMBER IT THIS WAY
A story beat: one picture-line that carries the order or the cause.
The rename test passed alone but failed in the full run, because both tests shared the same task title on the same server.
| In the trick | What it stands for |
|---|---|
| Passed alone | the browser room was clean |
| Failed in the full run | the problem was outside the room |
A unique title only helps if each test really uses its own.
TELL A FRIEND
A hotel gives each guest a clean room, but the building is shared. Playwright cleans the room, and the team must keep the building tidy.
OFTEN MIXED UP WITH Fixtures: shared setup without copy-paste. A fixture builds and cleans set-up for a test. Isolation says what a test may share with others.
Sources & standards — 4 sources
- Market practice
Isolation (Playwright documentation) ↗ — Microsoft (Playwright) · Each test gets its own browser context, a clean-slate profile like an incognito one, fast to create and fully isolated; a new context shares no cookies or cache with others; close contexts before the browser (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Best practices (Playwright documentation) ↗ — Microsoft (Playwright) · Recommends isolated tests that do not depend on each other (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail. A second search on 2026-10-20 returned this page for its title and matched the described content; the page was still not opened (search excerpt, page not opened).
- Market practice
Using HyperText Transfer Protocol (HTTP) cookies (Mozilla developer docs) ↗ — Mozilla (developer documentation) · After sign-in the server sets a cookie with a session identifier and the browser sends it back with later requests (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Authentication (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.
Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.
PRACTISE AND KEEP
Sources for this topic — 4 sources
- Market practice
Isolation (Playwright documentation) ↗ — Microsoft (Playwright) · Each test gets its own browser context, a clean-slate profile like an incognito one, fast to create and fully isolated; a new context shares no cookies or cache with others; close contexts before the browser (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Best practices (Playwright documentation) ↗ — Microsoft (Playwright) · Recommends isolated tests that do not depend on each other (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail. A second search on 2026-10-20 returned this page for its title and matched the described content; the page was still not opened (search excerpt, page not opened).
- Market practice
Using HyperText Transfer Protocol (HTTP) cookies (Mozilla developer docs) ↗ — Mozilla (developer documentation) · After sign-in the server sets a cookie with a session identifier and the browser sends it back with later requests (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Authentication (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.
Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.