Docker selenium/node-chrome - 量角器找不到Chrome二进制文件

dma*_*man 7 selenium docker protractor

我是Docker的新手,但不是E2E量角器.我正在尝试用docker容器构建E2E集成.

使用Docker跟随Angular的量角器烹饪书

他们有第2步-启动硒节点

docker run -d --link selenium-hub:hub selenium/node-chrome:latest

我了解Selnium Grid的功能 - 它允许通过与网格通信来测试不同类型的浏览器.

当我有这个Docker容器运行时,Protactor不会将它用作chrome二进制文件而且我得到了WebDriverError: unknown error: cannot find Chrome binary.

如何使量角器使用此node-chrome容器而不是本地chrome二进制文件?

我的量角器配置:

exports.config = {
  framework: 'mocha',
  directConnect: true,
  seleniumAddress: 'http://localhost:4444/wd/hub', // I have this set to the grid docker container from Angular cookbook
  specs: ['./stories/*.js'],
  onPrepare: function() {
    expect = require("chai").use(require("chai-as-promised")).expect;
  },
  mochaOpts: {
    enableTimeouts: false,
    reporter: "spec",
    slow: 7000
  },
  capabilities: {
    browserName: 'chrome'
  }
}
Run Code Online (Sandbox Code Playgroud)

这就是我在无头服务器上运行量角器的方法(非对接器) xvfb-run node_modules/protractor/bin/protractor e2e/protractor.conf.js

dma*_*man 3

我发现了这个问题...我directConnect: true在量角器配置中删除了它,这使得它可以在没有本地 chrome 二进制文件的情况下运行。解决方案是添加false或删除它。

来自文档:

directConnect: true - 您的测试脚本直接与 Chrome 驱动程序或 Firefox 驱动程序通信,绕过任何 Selenium 服务器。如果这是 true,seleniumAddress 和 seleniumServerJar 的设置将被忽略。如果您尝试使用 Chrome 或 Firefox 以外的浏览器,将会抛出错误

  • 我很高兴你发现了这个“问题”。如果您的驱动程序提供者与以下拉取请求发生冲突,Protractor 的下一版本应该向您发出警告:https://github.com/angular/protractor/pull/3873。 (2认同)