You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins中Playwright Trace Viewer显示空白的配置问题咨询

问题

我的测试报告html-result/index.html可正常访问,但trace文件夹下的文件显示空白,Trace Viewer的ZIP文件无法在浏览器中打开。请问如何正确配置Playwright Trace Viewer?注:无法通过localhost进行部署。

当前Jenkins发布HTML报告阶段配置:

publishHTML(
    allowMissing: false,
    alwaysLinkToLastBuild: true,
    keepAll: true,
    reportDir: 'html-Result/',
    reportFiles: 'index.html',
    reportName: "Playwright Report",
    traceFiles: 'html-Result/data/**/*.zip'
)

归档构件代码:

// Archive the HTML report as a build artifact
archiveArtifacts artifacts: "html-Result/*.html", followSymlinks: false, onlyIfSuccessful: false
archiveArtifacts artifacts: "html-Result/data/*.*", followSymlinks: false, onlyIfSuccessful: false
archiveArtifacts artifacts: "html-Result/trace/*.html", followSymlinks: false, onlyIfSuccessful: false
解决方案

1. 修正publishHTML的Trace文件关联配置

原配置中traceFiles仅指向data下的zip文件,未包含trace文件夹的HTML页面,导致两者关联失效。调整为同时包含trace页面和zip文件,同时开启不安全HTML加载权限避免浏览器拦截:

publishHTML(
    allowMissing: false,
    alwaysLinkToLastBuild: true,
    keepAll: true,
    reportDir: 'html-Result/',
    reportFiles: 'index.html',
    reportName: "Playwright Report",
    traceFiles: 'html-Result/trace/**/*.html,html-Result/data/**/*.zip',
    allowUnsafe: true
)

2. 优化归档构件的路径匹配

原归档配置中html-Result/data/*.*无法匹配子文件夹下的zip文件,改为递归匹配确保所有trace归档文件被正确捕获:

// Archive the HTML report as a build artifact
archiveArtifacts artifacts: "html-Result/*.html", followSymlinks: false, onlyIfSuccessful: false
archiveArtifacts artifacts: "html-Result/data/**/*.zip", followSymlinks: false, onlyIfSuccessful: false
archiveArtifacts artifacts: "html-Result/trace/**/*.html", followSymlinks: false, onlyIfSuccessful: false

3. 确保Playwright报告生成时使用相对路径

生成报告时指定相对输出路径,避免绝对URL导致的加载失败:

playwright test --reporter html --output html-Result

4. 排查浏览器加载错误

打开trace页面后,查看浏览器控制台的错误信息:

  • 若出现404错误:检查zip文件的相对路径是否正确,手动调整URL中trace=参数为相对路径(如../data/xxx.zip)验证是否能加载
  • 若出现CORS错误:确认Jenkins的HTML发布插件已启用allowUnsafe选项,或调整Jenkins的资源访问策略

内容的提问来源于stack exchange,提问作者Harish NR

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 14:43:13