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
Ensure Playwright version is 1.59 or later in your package.json
In your test, call await page.screencast.start({ path: 'recording.webm' }) at the point where you want recording to begin
Execute the actions you want captured
Call const screencast = await page.screencast.stop() to end recording and flush the video file to disk
Attach the file as a test artifact: await testInfo.attach('screencast', { path: 'recording.webm', contentType: 'video/webm' })
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
page.screencast is distinct from the context-level recordVideo option — both cannot be active simultaneously on the same page without conflicts
The output is a .webm file using VP8 encoding; on Windows some players require a codec install, and ffmpeg conversion to mp4 may be needed for wider compatibility
Calling screencast.stop() before all pending animations have resolved may clip the final frame; add a short waitForTimeout or wait for the relevant locator state first
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?