node.js - Azure管道中的UI测试显示错误无法使用node js找到chrome二进制文件

标签 node.js azure-pipelines

我正在尝试在 Azure Devops 管道中运行 UI 测试,我创建了 yaml 文件并添加了在 chrome 上运行 UItests 的命令,但收到错误“WebDriverError:未知错误:找不到 Chrome 二进制文件” 我正在使用 Node js 代码

这是 YAML 文件:

# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- master

pool:
  name: 'Default'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- script: |
    npm install
    npm run build
  displayName: 'npm install and build'

- task: Npm@1
  inputs:
    command: 'install'
    customCommand: 'iocContainer'
  displayName: 'npm iocContainer'

- task: CmdLine@2
  inputs:
    script: '.\runUITest.bat "@RecieveOnlineOrder"'

最佳答案

WebDriverError: unknown error: cannot find Chrome binary

问题似乎是 chrome 驱动程序找不到 chrome.exe 文件。

由于您使用的是自托管代理,因此您需要首先确保已在本地计算机上安装 Chrome。如果仅安装了 chrome 驱动程序,您将面临此问题。

您还可以尝试将 Chrome 驱动程序更新到最新。

如果您安装了Chrome,您可以检查chrome.exe的文件路径。

根据 the ChromeDriver - Requirements :

enter image description here

另一方面,这个问题可能与chrome版本有关,这是an open ticket有类似问题的可以引用一下。

您可以尝试运行以下脚本并检查它是否可以工作:

npm i chromedriver --chromedriver_version=LATEST --save-dev

关于node.js - Azure管道中的UI测试显示错误无法使用node js找到chrome二进制文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64638097/

相关文章:

.net - 使用混合 .NET Core 和框架解决方案的 Azure Devops 中的 Cake 构建脚本失败

c# - Azure Service Fabric 无法使用 ASP.NET Core 在 VSTS 上执行 CI

azure - 如何在运行时在 Powershell 中设置、重置或覆盖 Azure Pipelines 中的变量?

Node.js 应用程序在 Chromium 中无法正确加载 : Connection timed out while reading response header from upstream

javascript - 用于在 Eclipse 中进行 NodeJS 开发的 Nodeclipse 插件

javascript - 服务器从 Node 启动时如何运行 grunt?

azure-pipelines - 命令行构建任务来运行 exe

javascript - node.js 和 V8 builtins 是用 JS 编写的还是作为原生代码编译运行的?

windows - 在一个终端中启动多个工具,如 grunt 和 http-server

testing - VSTS 中 .NET Core 项目的代码覆盖率和测试结果