16. Browser, Context and Page Architecture

Multi-User Context Testing

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();
});

Task

  • Implement getContextConfig:
  • 1. Accept width and height numbers.
  • 2. Return { viewport: { width, height }, permissions: ["geolocation"] }.
πŸ’‘Common doubts
Did you like the problem?
Lesson 16 of 35
JavaScript
Loading code editor…
Next