If you want to record browser automation sessions as video for debugging, documentation, or proof of work, Playwright CLI already provides a fairly direct workflow. It produces WebM video using the VP8/VP9 codec.
This article follows the official video-recording reference and focuses on the parts that matter most in practice: the basic recording flow, chapter markers, full hero-script recording, the Overlay API, and the difference between video and tracing. The command lines, code snippets, and parameter details are preserved from the reference.
01 Basic Recording Flow
The basic pattern is simple: open the browser, start recording, perform actions, then stop and save.
|
|
These commands already cover the most common recording flow. video-chapter is useful for inserting chapter cards between stages so the final video is easier to follow.
02 Best Practices
1. Use Descriptive Filenames
If the video is meant for other people or for later review, the filename should include enough context to make it understandable at a glance.
|
|
2. Record Entire Hero Scripts
The official recommendation is that when a video is for a user or serves as proof of work, it is best to turn the scenario into a code snippet and execute it with run-code. That gives you better control over pacing, pauses, and annotations in the video. The reference also notes that Playwright now includes APIs designed specifically for this kind of recording flow.
The suggested process is:
- First perform the scenario with the CLI and note all locators and actions. You will need those locators later if you want their bounding boxes for highlight overlays.
- Create a dedicated script file for the video and write it in the style shown below. Use
pressSequentiallywithdelayfor smoother typing, and add pauses where they feel natural. - Use
playwright-cli run-code --filename your-script.js.
Important: Overlays are pointer-events: none — they do not interfere with page interactions. You can safely keep sticky overlays visible while clicking, filling, or performing any actions on the page.
|
|
The value of this script is not only that it records the flow, but that it makes the video easier to understand: chapter cards handle transitions, pressSequentially makes typing look natural, and showOverlay adds explanation, highlights, and context.
The reference closes this section with a short reminder: Embrace creativity, overlays are powerful.
03 Overlay API Summary
When recording video, the Overlay API is especially useful for section transitions, local callouts, and sticky annotations. The official summary is:
| Method | Use Case |
|---|---|
page.screencast.showChapter(title, { description?, duration?, styleSheet? }) |
Full-screen chapter card with blurred backdrop — ideal for section transitions |
page.screencast.showOverlay(html, { duration? }) |
Custom HTML overlay — use for callouts, labels, highlights |
disposable.dispose() |
Remove a sticky overlay added without duration |
page.screencast.hideOverlays() / page.screencast.showOverlays() |
Temporarily hide/show all overlays |
If your goal is to turn automation into a video people can comfortably watch, this API set is one of the most valuable pieces to learn first.
04 Tracing vs Video
The official documentation makes the difference between the two very clear:
| Feature | Video | Tracing |
|---|---|---|
| Output | WebM file | Trace file (viewable in Trace Viewer) |
| Shows | Visual recording | DOM snapshots, network, console, actions |
| Use case | Demos, documentation | Debugging, analysis |
| Size | Larger | Smaller |
A simple way to think about it:
videois better for demos, delivery, and reviewing what a user would seetracingis better for debugging, inspecting action details, and analyzing execution context
They are not replacements for each other. Each serves a different purpose.
05 Limitations
The reference also points out two practical limitations:
- Recording adds slight overhead to automation
- Large recordings can consume significant disk space
So while video recording is very useful, it does add some runtime overhead, and longer recordings can grow large on disk.
06 Quick Summary
If you only want the essentials, remember these points:
video-start/video-stopare the core commands for recordingvideo-chapteradds section transitions and makes demos easier to follow- More advanced recording scenarios are best written as scripts and executed with
run-code showOverlayandshowChaptercan significantly improve video readabilityvideois best for demos, whiletracingis best for debugging
If your workflow already includes automation demos, acceptance evidence, or proof-of-work recordings, video recording is a very worthwhile part of Playwright CLI to add.
References
- Playwright CLI video-recording reference: https://github.com/microsoft/playwright-cli/blob/main/skills/playwright-cli/references/video-recording.md
- Playwright CLI project homepage: https://github.com/microsoft/playwright-cli