Install
openclaw skills install @13770626440/e2e-test-recorderRecords browser interactions for end-to-end tests and generates videos or GIFs with configurable encoding and annotations.
openclaw skills install @13770626440/e2e-test-recorder基于 Puppeteer 的自动化端到端测试录制 Skill,支持录制浏览器操作并生成演示视频/GIF。
npm install puppeteer puppeteer-screen-recorder ffmpeg-static
# 或
yarn add puppeteer puppeteer-screen-recorder ffmpeg-static
const { ScreenRecorder } = require('./scripts/record-browser');
const recorder = new ScreenRecorder({
outputPath: './recordings/demo.mp4',
fps: 30,
quality: 80
});
await recorder.startRecording('https://your-app.com');
// 执行操作...
await recorder.stopRecording();
const { recordE2ETest } = require('./scripts/record-test');
await recordE2ETest({
url: 'http://localhost:3000',
testSteps: [
{ action: 'click', selector: '#login-btn' },
{ action: 'type', selector: '#username', text: 'testuser' },
{ action: 'type', selector: '#password', text: 'password123' },
{ action: 'click', selector: '#submit-btn' }
],
output: './recordings/login-test.mp4'
});
new ScreenRecorder(options)
options:
outputPath (string): 输出文件路径fps (number): 帧率,默认 30quality (number): 视频质量 0-100,默认 80aspectRatio (string): 宽高比,如 '16:9'codec (string): 视频编码器,默认 'libx264'startRecording(url, options): 开始录制stopRecording(): 停止录制pauseRecording(): 暂停录制resumeRecording(): 恢复录制addAnnotation(text, position): 添加标注addWatermark(imagePath, position): 添加水印录制端到端测试过程
config:
url (string): 测试页面URLtestSteps (Array): 测试步骤数组output (string): 输出文件路径headless (boolean): 是否无头模式,默认 false视频格式转换
合并多个视频文件
{
"recorder": {
"fps": 30,
"quality": 80,
"outputDir": "./recordings",
"defaultFormat": "mp4"
},
"browser": {
"headless": false,
"viewport": { "width": 1920, "height": 1080 },
"slowMo": 50
},
"annotations": {
"enabled": true,
"fontSize": 24,
"fontColor": "#ffffff",
"backgroundColor": "#00000080"
}
}
{
"testSuites": {
"login": {
"url": "http://localhost:3000/login",
"steps": "scripts/test-steps/login.json",
"output": "recordings/login-test.mp4"
},
"dashboard": {
"url": "http://localhost:3000/dashboard",
"steps": "scripts/test-steps/dashboard.json",
"output": "recordings/dashboard-test.mp4"
}
}
}
// jest.config.js
module.exports = {
setupFilesAfterEnv: ['./jest.setup.js'],
reporters: [
'default',
['./scripts/jest-video-reporter', { outputDir: './test-recordings' }]
]
};
// playwright.config.js
const { defineConfig } = require('@playwright/test');
module.exports = defineConfig({
use: {
video: 'on',
screenshot: 'on',
},
reporter: [
['html', { outputFolder: 'playwright-report' }],
['./scripts/playwright-video-reporter', { format: 'gif' }]
]
});
e2e-test/
├── SKILL.md # 技能文档
├── package.json # 项目配置
├── scripts/
│ ├── record-browser.js # 浏览器录制核心
│ ├── record-test.js # 测试录制
│ ├── record-screen.js # 屏幕录制
│ ├── convert-format.js # 格式转换
│ ├── add-annotations.js # 添加标注
│ └── utils.js # 工具函数
├── configs/
│ ├── default.json # 默认配置
│ ├── test.json # 测试配置
│ └── production.json # 生产配置
├── templates/
│ ├── demo-template.js # 演示模板
│ └── test-template.js # 测试模板
├── examples/
│ ├── basic-recording.js # 基础录制示例
│ ├── e2e-test.js # 端到端测试示例
│ └── api-test.js # API测试示例
└── recordings/ # 录制文件输出目录
const { recordE2ETest } = require('./scripts/record-test');
await recordE2ETest({
url: 'http://localhost:3000',
testName: '用户登录测试',
steps: [
{
description: '访问登录页面',
action: 'goto',
url: '/login'
},
{
description: '输入用户名',
action: 'type',
selector: '#username',
text: 'test@example.com'
},
{
description: '输入密码',
action: 'type',
selector: '#password',
text: 'password123'
},
{
description: '点击登录按钮',
action: 'click',
selector: 'button[type="submit"]'
},
{
description: '验证登录成功',
action: 'waitFor',
selector: '.dashboard',
timeout: 5000
}
],
output: 'recordings/login-demo.mp4',
annotations: true
});
const { recordAPITest } = require('./scripts/record-test');
await recordAPITest({
apiUrl: 'http://localhost:8000/api',
tests: [
{
name: '健康检查API',
endpoint: '/health',
method: 'GET',
expectedStatus: 200
},
{
name: '用户注册API',
endpoint: '/auth/register',
method: 'POST',
data: {
username: 'testuser',
email: 'test@example.com',
password: 'Password123!'
},
expectedStatus: 201
}
],
output: 'recordings/api-test.gif'
});
executablePathfps 和 quality 参数,确保网络稳定fps、quality,或使用 convertVideo 压缩const recorder = new ScreenRecorder({
debug: true, // 启用调试模式
logLevel: 'verbose'
});
MIT License