HLJ 发布于
2022-11-05 12:33:20

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);
当前文章内容为原创转载请注明出处:http://www.good1230.com/detail/2022-11-05/614.html
最后生成于 2023-08-15 14:32:47
此内容有帮助 ?
0