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

如何在Azure Pipeline中指定Playwright Chromium版本?

指定Playwright使用的Chromium版本解决方案

方法一:通过锁定Playwright版本匹配目标Chromium

Playwright的每个版本都绑定固定的浏览器版本,先找到对应Chromium 126的Playwright版本(例如Playwright v1.45.x系列对应Chromium 126.0.6478.126),再按以下步骤操作:

  • 在项目的package.json中,明确指定playwright和@playwright/test(若使用)的版本:
    {
      "devDependencies": {
        "@playwright/test": "1.45.0",
        "playwright": "1.45.0"
      }
    }
    
  • 修改Azure流水线的PowerShell脚本,清理旧依赖后重新安装:
    npm uninstall playwright @playwright/test
    npm install
    npx playwright install chromium
    
    执行后会自动下载与Playwright 1.45.0绑定的Chromium 126版本。

方法二:直接指定Chromium版本安装

若需单独指定Chromium版本(需确保与当前Playwright版本兼容),可调整安装命令:

  • 将Azure流水线中的安装命令修改为:
    npm install
    npx playwright install chromium@126.0.6478.126
    
    注意:此方法需确认该Chromium版本与你的Playwright版本兼容,否则可能出现运行时错误。

针对.NET项目(NuGet场景)

如果是使用.NET版本的Playwright,NuGet包Microsoft.Playwright也绑定对应浏览器版本:

  • 在VS中安装Microsoft.Playwright的1.45.0版本(对应Chromium 126)
  • 在Azure流水线中执行以下命令:
    dotnet tool install --global Microsoft.Playwright.CLI
    playwright install chromium
    
    此时会自动下载与NuGet包版本匹配的Chromium 126。

额外注意事项

  • 若流水线启用了缓存,需清理npm或NuGet缓存,避免旧版本或不兼容版本残留
  • 确认Azure代理环境的网络权限允许下载指定版本的Chromium安装包

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.21 19:52:07