Playwright + Java · Lesson 16 of 38
Module 16: Playwright Browser Concepts
Your task
Create a helper method countOpenPages:
Write it in the editor, then press Check answer (Ctrl + Enter).
Playwright: The top-level connection to the driver.Browser: The browser process (Chromium, Firefox, WebKit).BrowserContext: An incognito profile with separate cookies, cache, and localStorage.Page: A single browser tab or window.try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch();
BrowserContext context = browser.newContext();
Page page = context.newPage();
page.navigate("https://targetqa.com");
}Understanding Playwright's hierarchy is crucial. A single Browser instance can host dozens of completely isolated BrowserContexts. Each Context has its own cookies and session storage, enabling multi-user and parallel testing without overhead. Let's master Contexts!
Part of the Playwright + Java course (Playwright with Java). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.
BrowserContext creates a full incognito profile in milliseconds with almost zero CPU/RAM overhead, whereas launching a new Browser takes seconds.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___