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

本地用Playwright(macOS):Chrome测试正常,Webkit/Firefox启动即崩溃

解决macOS下Playwright Webkit/Firefox启动后立即关闭的问题

针对Chrome可正常运行,但Webkit与Firefox启动后立即关闭的情况,结合报错信息(worker process exited unexpectedly (code=null, signal=SIGABRT)、kCFErrorDomainCFNetwork error 310),试试以下修复方案:

  • 禁用网络代理或VPN
    kCFErrorDomainCFNetwork错误310多和代理配置冲突有关。先关闭全局VPN、系统代理,也可以在测试代码中强制跳过代理:

    const browser = await playwright.webkit.launch({
      proxy: { server: 'direct://' }
    });
    
  • 重装Playwright浏览器二进制文件
    依赖更新不代表浏览器二进制文件完好,执行命令重新安装Webkit和Firefox:

    npx playwright install webkit firefox
    

    若无效,彻底清理缓存后重装:

    npx playwright uninstall webkit firefox
    rm -rf ~/.cache/ms-playwright
    npx playwright install webkit firefox
    
  • 检查系统权限设置
    确保运行测试的终端/IDE拥有足够权限:

    1. 打开「系统设置」-「隐私与安全性」
    2. 确认「完全磁盘访问权限」「网络」列表中包含你的终端(如iTerm)或IDE(如VS Code)
    3. 重启终端/IDE后重新运行测试
  • 验证系统版本兼容性
    Playwright对macOS版本有要求(如1.40+需macOS 10.15及以上),旧系统可能导致Webkit/Firefox进程崩溃,检查并升级系统到兼容版本。

  • 用最简代码排查业务逻辑干扰
    编写基础测试代码,排除业务代码的影响:

    const { test, expect } = require('@playwright/test');
    
    test('webkit basic test', async ({ page }) => {
      await page.goto('https://www.google.com');
      await expect(page).toHaveTitle(/Google/);
    });
    

    指定浏览器运行测试:

    npx playwright test --project=webkit
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 08:12:46