Manuals / Playwright with Python / Chapter 8
Part 1 · Foundations · beginner · ~40 min · Chapter 8 of 61
3. Playwright Architecture
Browser, BrowserContext, Page hierarchy This is the conceptual backbone of the entire tool, so it's worth internalizing precisely: ● Browser — one actual browser process (e.g., one Chromium instance). Launching a browser is relatively expensive (time and memory), so you typically launch one per test session, not one per test.
Step 1 of 3
Overview
Browser, BrowserContext, Page hierarchy This is the conceptual backbone of the entire tool, so it's worth internalizing precisely: session, not one per test. incognito window. Each context has its own cookies, local storage, cache, and permissions — completely separate from other contexts in the same browser. Creating a new context is cheap and fast, which is why the recommended pattern is: one browser launch per session, one new context per test (for isolation between tests), and reuse the browser itself. simultaneously (this is how multi-tab testing in Chapter 9 works). Why this hierarchy matters practically: it's the reason Playwright can cheaply simulate multiple independent users (Part 0/2's "multi-user simulation") without needing to launch multiple full browser processes — you just open multiple contexts within one browser. It's also why test isolation is easy to get right by default: if every test gets a fresh context, cookies/login state from one test can't accidentally leak into another.
Chapter learning outcomes
- Overview (2)
- Overview (3)
Clear these before you leave
Side quest
3. Playwright Architecture deliverable
Apply one idea from “Overview” in a small script or note.