7. Browser, Context and Page Architecture

Context Isolation

Every test receives an isolated page fixture.
test("multi-user session testing", async ({ browser }) => {
  // User 1: Buyer
  const buyerContext = await browser.newContext();
  const buyerPage = await buyerContext.newPage();
  await buyerPage.goto("https://targetqa.com");

// User 2: Admin (completely isolated cookies and storage)
const adminContext = await browser.newContext();
const adminPage = await adminContext.newPage();
await adminPage.goto("https://targetqa.com/admin");

await buyerContext.close();
await adminContext.close();
});

Task

  • Implement getContextDimensions:
  • 1. Accept options with width and height numbers.
  • 2. Return { viewport: { width: options.width, height: options.height } }.
πŸ’‘Common doubts
Did you like the problem?
Lesson 7 of 18
JavaScript
Loading code editor…
Next