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
- Launch or connect to a browser engine.
- Create one or more browser contexts.
- Open pages inside those contexts.
- 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.