视频录制#
使用 record 将浏览器自动化录制为 WebM 视频,可用于调试、CI 证据、产品演示或复现报告。
基本流程#
bash
agent-browser open https://example.com
agent-browser record start ./demo.webm
agent-browser snapshot -i
agent-browser click @e1
agent-browser record stopAfter launching a session, record start can also navigate immediately:
bash
agent-browser open
agent-browser record start ./demo.webm https://example.comIf no URL is provided, recording starts from the current page. The recording context copies cookies from the active session.
命令#
| Command | Description |
|---|---|
record start <path.webm> [url] | Start recording to a WebM file |
record stop | Stop the active recording and save the file |
record restart <path.webm> [url] | Stop the current recording and immediately start another |
CI 证据#
bash
#!/bin/bash
set -e
cleanup() {
agent-browser record stop 2>/dev/null || true
agent-browser close 2>/dev/null || true
}
trap cleanup EXIT
agent-browser open https://app.example.com/login
agent-browser record start "./artifacts/login-flow.webm"
agent-browser snapshot -i
agent-browser fill @e1 "demo@example.com"
agent-browser fill @e2 "password"
agent-browser click @e3
agent-browser wait --url "**/dashboard"当仅靠文本输出很难诊断浏览器故障时,把录制文件作为 CI 产物保留下来。
适合人工观看的演示#
Add small waits when the video is meant for a person to watch:
bash
agent-browser open https://shop.example.com
agent-browser record start ./checkout.webm
agent-browser wait 500
agent-browser click @e4
agent-browser wait 500
agent-browser screenshot ./screenshots/cart.png
agent-browser record stop截图和视频配合使用效果很好:截图能捕捉精确静态状态,而视频则能展示时序、过渡和意外遮罩。
输出格式#
| Property | Value |
|---|---|
| Container | WebM |
| Common extension | .webm |
| Viewport | Uses the active browser viewport settings |
| State | Copies cookies from the active session |
限制#
- Recording adds overhead to automation.
- Long recordings can use significant disk space.
- Use
record stopbefore closing a session if you need the file flushed. - Some constrained headless environments may have codec or GPU limitations.