HLJ
发布于
2022-11-05 12:33:20
playwright 测试用例记录跟踪保存文件
上一篇文章:
playwright 指令
测试用例
const http = require('http');
const { chromium, expect, test } = require('@playwright/test');
http.createServer(function (req, res) {
(async () => {
const browser = await chromium.launch({ headless: false });
const context = await browser.newContext()
const page = await context.newPage();
//在创建/导航页面之前开始跟踪
const obj = {
screenshots: true,
snapshots: true,
sources: true
}
await context.tracing.start(obj)
await page.goto('http://www.good1230.com/');
// 停止跟踪并将其导出到 zip 存档中。
await context.tracing.stop({ path: "trace.zip" })
})();
res.writeHead(200, { 'Content-Type': 'text/html' });
res.write('Node.js says hello!');
res.end();
}).listen(8080);
- 运行node xxx.js文件生成记录文件zip包
记录跟踪运行命令
playwright show-trace trace.zip
https://playwright.dev/docs/intro
最后生成于 2022-11-21 22:22:37
上一篇文章: