Playwright BrowserContext mirrors page lifecycle events
Introduced 2026-05-11 · score 0.99
HOW TO USE IT
When monitoring lifecycle activity across every page in a browser context, register listeners on the `BrowserContext` for the events you need. Each callback receives a `Download`, `Frame`, or `Page`, as documented for that event.
context.on('download', download => {});
context.on('frameattached', frame => {});
context.on('framedetached', frame => {});
context.on('framenavigated', frame => {});
context.on('pageclose', page => {});
context.on('pageload', page => {});WHY THIS HELPS
Monitor downloads, frame lifecycle, page closure, and page load across pages in a browser context.
REQUIREMENTS AND LIMITATIONS
- Version: v1.60.0
- event name (`download`, `frameattached`, `framedetached`, `framenavigated`, `pageclose`, or `pageload`) (required): Selects which context event to listen for. The events report a download starting, a frame attaching/detaching/navigating, a page closing, or a page's JavaScript `load` event being dispatched, respectively.
- listener callback (`data => {}`) (required): Receives the event data: `Download` for `download`, `Frame` for the three frame events, and `Page` for `pageclose` and `pageload`.
- Prerequisite: Use Playwright v1.60.0 or later; the six context event APIs are documented as added in v1.60.
FIRST-PARTY EVIDENCE
- https://github.com/microsoft/playwright/releases/tag/v1.60.0
- https://playwright.dev/docs/api/class-browsercontext
Check the installed version and the source before using it. Entry JSON