Record video mid-test on demand using Playwright page.screencast.start() and stop() (v1.59+)

domain: playwright.dev · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Ensure Playwright version is 1.59 or later in your package.json
  2. In your test, call await page.screencast.start({ path: 'recording.webm' }) at the point where you want recording to begin
  3. Execute the actions you want captured
  4. Call const screencast = await page.screencast.stop() to end recording and flush the video file to disk
  5. Attach the file as a test artifact: await testInfo.attach('screencast', { path: 'recording.webm', contentType: 'video/webm' })
  6. For streaming frames to a vision model in real time, use the onFrame callback in the start options to receive each frame as a Buffer

Known gotchas

Related routes

record video only for failed tests using playwright's use.video retain-on-failure option
playwright.dev · 5 steps · unrated
assert on websocket frames in a playwright test using page.waitforevent('websocket')
playwright.dev · 5 steps · unrated
Record a HAR file in Playwright and replay it for deterministic offline test mocking
playwright.dev · 5 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans