Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Automate browser interactions for web testing, form filling, screenshots, and data extraction using the playwright-cli tool.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/video-recording.md
1# Video Recording23Capture browser automation sessions as video for debugging, documentation, or verification. Produces WebM (VP8/VP9 codec).45## Basic Recording67```bash8# Open browser first9playwright-cli open1011# Start recording12playwright-cli video-start demo.webm1314# Add a chapter marker for section transitions15playwright-cli video-chapter "Getting Started" --description="Opening the homepage" --duration=20001617# Navigate and perform actions18playwright-cli goto https://example.com19playwright-cli snapshot20playwright-cli click e12122# Add another chapter23playwright-cli video-chapter "Filling Form" --description="Entering test data" --duration=200024playwright-cli fill e2 "test input"2526# Stop and save27playwright-cli video-stop28```2930## Best Practices3132### 1. Use Descriptive Filenames3334```bash35# Include context in filename36playwright-cli video-start recordings/login-flow-2024-01-15.webm37playwright-cli video-start recordings/checkout-test-run-42.webm38```3940### 2. Record entire hero scripts.4142When recording a video for the user or as a proof of work, it is best to create a code snippet and execute it with run-code.43It allows pulling appropriate pauses between the actions and annotating the video. There are new Playwright APIs for that.44451) Perform scenario using CLI and take note of all locators and actions. You'll need those locators to request their bounding boxes for highlight.462) Create a file with the intended script for video (below). Use pressSequentially w/ delay for nice typing, make reasonable pauses.473) Use playwright-cli run-code --filename your-script.js4849**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.5051```js52async page => {53await page.screencast.start({ path: 'video.webm', size: { width: 1280, height: 800 } });54await page.goto('https://demo.playwright.dev/todomvc');5556// Show a chapter card — blurs the page and shows a dialog.57// Blocks until duration expires, then auto-removes.58// Use this for simple use cases, but always feel free to hand-craft your own beautiful59// overlay via await page.screencast.showOverlay().60await page.screencast.showChapter('Adding Todo Items', {61description: 'We will add several items to the todo list.',62duration: 2000,63});6465// Perform action66await page.getByRole('textbox', { name: 'What needs to be done?' }).pressSequentially('Walk the dog', { delay: 60 });67await page.getByRole('textbox', { name: 'What needs to be done?' }).press('Enter');68await page.waitForTimeout(1000);6970// Show next chapter71await page.screencast.showChapter('Verifying Results', {72description: 'Checking the item appeared in the list.',73duration: 2000,74});7576// Add a sticky annotation that stays while you perform actions.77// Overlays are pointer-events: none, so they won't block clicks.78const annotation = await page.screencast.showOverlay(`79<div style="position: absolute; top: 8px; right: 8px;80padding: 6px 12px; background: rgba(0,0,0,0.7);81border-radius: 8px; font-size: 13px; color: white;">82✓ Item added successfully83</div>84`);8586// Perform more actions while the annotation is visible87await page.getByRole('textbox', { name: 'What needs to be done?' }).pressSequentially('Buy groceries', { delay: 60 });88await page.getByRole('textbox', { name: 'What needs to be done?' }).press('Enter');89await page.waitForTimeout(1500);9091// Remove the annotation when done92await annotation.dispose();9394// You can also highlight relevant locators and provide contextual annotations.95const bounds = await page.getByText('Walk the dog').boundingBox();96await page.screencast.showOverlay(`97<div style="position: absolute;98top: ${bounds.y}px;99left: ${bounds.x}px;100width: ${bounds.width}px;101height: ${bounds.height}px;102border: 1px solid red;">103</div>104<div style="position: absolute;105top: ${bounds.y + bounds.height + 5}px;106left: ${bounds.x + bounds.width / 2}px;107transform: translateX(-50%);108padding: 6px;109background: #808080;110border-radius: 10px;111font-size: 14px;112color: white;">Check it out, it is right above this text113</div>114`, { duration: 2000 });115116await page.screencast.stop();117}118```119120Embrace creativity, overlays are powerful.121122### Overlay API Summary123124| Method | Use Case |125|--------|----------|126| `page.screencast.showChapter(title, { description?, duration?, styleSheet? })` | Full-screen chapter card with blurred backdrop — ideal for section transitions |127| `page.screencast.showOverlay(html, { duration? })` | Custom HTML overlay — use for callouts, labels, highlights |128| `disposable.dispose()` | Remove a sticky overlay added without duration |129| `page.screencast.hideOverlays()` / `page.screencast.showOverlays()` | Temporarily hide/show all overlays |130131## Tracing vs Video132133| Feature | Video | Tracing |134|---------|-------|---------|135| Output | WebM file | Trace file (viewable in Trace Viewer) |136| Shows | Visual recording | DOM snapshots, network, console, actions |137| Use case | Demos, documentation | Debugging, analysis |138| Size | Larger | Smaller |139140## Limitations141142- Recording adds slight overhead to automation143- Large recordings can consume significant disk space144