Playwright + JS · Lesson 16 of 35
Module 16: Browser, Context & Page
Try it yourself
Implement getContextConfig:
The editor has a worked example. Read it, tweak it, then press Mark as complete.
import { test } from "@playwright/test";
test("multi-user chat between Buyer and Support", async ({ browser }) => {
// Session 1: Buyer
const buyerContext = await browser.newContext();
const buyerPage = await buyerContext.newPage();
await buyerPage.goto("/chat");
await buyerPage.fill("#message", "I need assistance");
await buyerPage.click("#send");
// Session 2: Support agent (isolated cookies and storage)
const agentContext = await browser.newContext();
const agentPage = await agentContext.newPage();
await agentPage.goto("/support");
await agentPage.getByText("I need assistance").waitFor();
await buyerContext.close();
await agentContext.close();
});Playwright's BrowserContext architecture allows you to create completely isolated incognito profiles in milliseconds. In this lesson, we explore browser contexts, page tabs, permissions, and multi-user session testing in JavaScript. Let's take a look!
Part of the Playwright + JS course (Playwright with JavaScript). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.
A new browser process takes several seconds and hundreds of megabytes of RAM. A BrowserContext takes under 20 milliseconds and guarantees 100% cookie and storage isolation.
Finished reading?
Review the worked example in the editor, then mark the lesson complete.