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 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp