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

如何在WSL2中正常运行Playwright Inspector?

解决WSL2中Playwright Inspector窗口为空的问题

针对你遇到的WSL2环境下Playwright Inspector显示为空的问题,可尝试以下几种解决方案:

  • 升级WSL及WSLg组件
    你的WSLg版本(1.0.47)存在已知的GUI渲染兼容性问题,执行以下命令升级到最新版本:

    wsl --update
    wsl --shutdown
    

    重启WSL后再次尝试启动Inspector。

  • 禁用Playwright硬件加速
    WSLg的GPU渲染可能与Playwright Inspector冲突,通过环境变量禁用硬件加速后启动:

    PLAYWRIGHT_DISABLE_GPU=1 npx playwright codegen google.de -b wk --viewport-size "1024,768"
    
  • 切换浏览器后端测试
    当前使用的WebKit(-b wk)可能与WSLg的Inspector存在兼容问题,尝试切换到Chromium或Firefox验证:

    # 用Chromium启动Inspector
    npx playwright codegen google.de -b chromium --viewport-size "1024,768"
    # 用Firefox启动Inspector
    npx playwright codegen google.de -b firefox --viewport-size "1024,768"
    

    如果其他浏览器能正常显示Inspector,可暂时使用该替代方案,等待Playwright或WSLg的更新修复WebKit的兼容问题。

  • 更新Playwright到最新版本
    旧版Playwright可能与当前WSL环境不兼容,执行以下命令更新并确保依赖完整:

    npm update playwright
    npx playwright install --with-deps
    
  • 验证DISPLAY变量配置
    确认WSL的DISPLAY变量设置正确,先执行echo $DISPLAY查看输出(通常为:0),然后指定该变量启动Inspector:

    DISPLAY=:0 npx playwright codegen google.de -b wk --viewport-size "1024,768"
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.02 13:40:35