Playwright tracing adds scoped HAR recording
Introduced 2026-05-11 · score 0.97
HOW TO USE IT
When recording network traffic for a browser workflow in Playwright v1.60.0 or later, call `context.tracing.startHar()` with the HAR path and any needed filters, then dispose its returned handle to save the HAR.
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const context = await browser.newContext();
await using har = await context.tracing.startHar('trace.har', {
content: 'embed',
mode: 'full',
urlFilter: '**/*',
});
const page = await context.newPage();
await page.goto('https://playwright.dev');
await browser.close();
})();WHY THIS HELPS
Record network traffic while running a browser workflow for debugging or replay.
REQUIREMENTS AND LIMITATIONS
- Version: v1.60.0
- path (required) (required): Filesystem path for the HAR. A .zip extension saves a ZIP archive with response bodies as separate files.
- options.content (optional): Resource content handling: omit, embed, or attach. Defaults to attach for .zip output and embed for other extensions.
- options.mode (optional): HAR detail level: full or minimal. Minimal keeps information needed for HAR routing; defaults to full.
- options.urlFilter (optional): Glob or regular expression filtering requests stored in the HAR; defaults to no filter.
- Prerequisite: Requires Playwright v1.60 or later; tracing.startHar was added in v1.60.
FIRST-PARTY EVIDENCE
- https://github.com/microsoft/playwright/releases/tag/v1.60.0
- https://playwright.dev/docs/api/class-tracing
Check the installed version and the source before using it. Entry JSON