Playwright + TS · Lesson 16 of 36
Module 16: Browser, Context & Page
Try it yourself
Implement createIsolatedSessionConfig:
The editor has a worked example. Read it, tweak it, then press Mark as complete.
In this lesson
Browser (1 Heavy OS Process, e.g. Chromium)
├── BrowserContext 1 (Isolated incognito profile: cookies, cache, storage)
│ ├── Page 1 (Tab / Window)
│ └── Page 2 (Second Tab)
└── BrowserContext 2 (Totally independent user session, e.g. Admin vs Buyer)
└── Page 1By default, every single test receives a fresh page fixture. Behind the scenes:
BrowserContext in under 20ms.Page inside it.import { test } from "@playwright/test";
test("multi-user chat interaction", async ({ browser }) => {
// User 1: Alice
const aliceContext = await browser.newContext();
const alicePage = await aliceContext.newPage();
await alicePage.goto("https://chat.targetqa.com");
await alicePage.fill("#msg", "Hello Bob!");
await alicePage.click("#send");
// User 2: Bob (Completely isolated storage and cookies!)
const bobContext = await browser.newContext();
const bobPage = await bobContext.newPage();
await bobContext.grantPermissions(["notifications"]);
await bobPage.goto("https://chat.targetqa.com");
// Verify Bob received message
await bobPage.getByText("Hello Bob!").waitFor();
await aliceContext.close();
await bobContext.close();
});One of Playwright's greatest strengths is its BrowserContext architecture. In traditional tools, starting a new session meant launching an entire heavy browser process. In Playwright, browser contexts act like ultra-fast incognito profiles created in milliseconds. In this lesson, we will explore browsers, contexts, pages, multi-tab handling, and storage isolation. Let's take a look!
Part of the Playwright + TS course (Playwright with TypeScript). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.
Launching a browser process takes 1-3 seconds and consumes hundreds of MBs of RAM. Creating a BrowserContext takes 10 milliseconds and shares the underlying browser binary while guaranteeing 100% cookie and storage isolation.
Use 'context.waitForEvent("page")' right before clicking a link with target="_blank" to capture the new Page instance.
Finished reading?
Review the worked example in the editor, then mark the lesson complete.