Architecture

Browser in Playwright

A Playwright browser represents the browser engine instance, such as Chromium, Firefox, or WebKit, used to create isolated contexts and pages.

Definition and Brief Explanation

Definition: A browser is the top-level Playwright object that represents a running browser engine.

Explanation: In most Playwright Test files you use the ready-made page fixture, but the browser object is important for understanding architecture and for advanced setup where you create contexts manually.

Lifecycle

  1. Launch or connect to a browser engine.
  2. Create one or more browser contexts.
  3. Open pages inside those contexts.
  4. Close the browser when manual setup is complete.

Example

Manual browser flow

const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();

Explanation: This shows the object chain from browser to context to page.

Common Confusion

  • Do not manually launch a browser inside every normal test when fixtures already provide page.
  • Test isolation usually belongs to browser context, not browser.
  • Passing in Chromium does not automatically prove Firefox and WebKit behavior.