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

在GitHub托管Windows运行器上运行GUI应用报错,求解决方案

问题描述

在GitHub托管的windows-2022运行器上尝试通过WinAppDriver启动Windows计算器(包名Microsoft.WindowsCalculator_8wekyb3d8bbwe!App)时,出现错误:WebDriverException: Package was not found。

用户的GitHub Actions工作流配置如下:

# ISSUE fails with WebDriverException: Package was not found
# see https://github.com/QA-Automation-Starter/qa-automation/actions/runs/3234841483/jobs/5298454871

build-and-test-on-windows:
  name: windows build&test
  runs-on: windows-2022
  environment: development

  steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-java@v3
      with:
        java-version: '8'
        distribution: 'temurin'
        cache: maven
        settings-path: ${{ github.workspace }}

    # ISSUE somehow should run WinAppDriver
    # see https://github.com/microsoft/WinAppDriver/issues/1722
    # and https://github.com/actions/runner-images/blob/main/images/win/Windows2022-Readme.md

    # TODO maybe, should re-publish the site from here (?)
    - run: |
        choco install -y autologon
        autologon %USERNAME% $USERDOMAIN%
        start cmd /c "C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe"
        cd qa-testing-example
        mvn install ^
          -s %GITHUB_WORKSPACE%\settings.xml ^
          -Pmode-build-fast,mode-build-quiet,environment-default,testing-windows,device-windows
      shell: cmd
解决方案建议
  • 验证计算器包名的正确性
    运行器上的计算器包名可能存在差异,先在运行器中执行Get-AppxPackage *Calculator*命令确认准确的包名和入口点,替换测试代码中的包名。

  • 确保WinAppDriver完全启动后再执行测试
    当前脚本启动WinAppDriver后立即执行Maven命令,可能WinAppDriver还未就绪。添加等待时间,比如在启动WinAppDriver后加入timeout /t 10 /nobreak命令,等待服务启动。

  • 处理GitHub运行器的交互式会话限制
    GitHub托管运行器默认在非交互式会话中运行,GUI应用可能无法正常加载。可以尝试:

    1. 运行autologon /acceptEula接受许可协议,避免autologon配置失败
    2. 使用start /b "WinAppDriver" "C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe"命令,让服务在后台运行,避免cmd窗口关闭导致服务终止
  • 确认计算器应用已安装并可正常访问
    虽然windows-2022镜像默认包含计算器,但可以在脚本中先执行Get-AppxPackage Microsoft.WindowsCalculator验证,如果未安装或状态异常,执行Add-AppxPackage -Register "C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_*\AppxManifest.xml" -DisableDevelopmentMode重新注册应用。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 03:15:36