How context works in playwright
👀 From the user’s perspective (what you see)
-
If you launch Playwright in headful mode, each context opens its own window.
- You’ll literally see multiple Chrome (or Firefox, Safari) windows.
- Each one can be logged into a different account, use different cookies, etc.
-
They behave just like separate browsers — isolated and independent.
- For example, Context A is logged into Gmail as “user1”
- Context B can be logged into Gmail as “user2” — in the same test run.
⚙️ From Playwright’s perspective (under the hood)
-
All those “windows” share the same browser process (same underlying Chrome binary).
-
Playwright efficiently isolates each context within that single process, saving:
- CPU and memory (vs. launching multiple browser instances)
- Time (launching a context is milliseconds, launching a browser is seconds)
-
Each context has its own:
- Cookies
- Local/session storage
- Cache
- Authentication state
🧩 Analogy
Think of it like multiple user profiles opened in the same Chrome instance — each profile has its own data and cookies, but all share the same executable and engine.
Published on: Oct 17, 2025, 10:01 AM