Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 649 Bytes

Recording Network Requests with Playwright.md

File metadata and controls

29 lines (22 loc) · 649 Bytes

Recording Network Requests with Playwright

With Playwright, you can record network requests into a HAR file.

You can either do that from the CLI:

npx playwright open --save-har=network-requests.har --save-har-glob="**/api**" http://localhost:3000

Or, from Playwright itself.

const context = await browser.newContext({
  recordHar: {
    mode: 'minimal',
    path: './network-requests.har',
  },
  serviceWorkers: 'block',
});

Replaying

await browserContext.routeFromHAR(har);
await browserContext.routeFromHAR(har, { update: true });
await browserContext.routeFromHAR(har, { update: true, url: '**/api**' });