Использование драйвера Chrome в тесте Protractor, запущенном в Docker

Alexander Mills спросил: 13 октября 2017 в 06:31 в: google-chrome

У меня возникли некоторые проблемы с настройкой Chrome для работы в Docker с Protractor, вот мой файл protractor.conf.js:

'use strict';const seleniumHost = process.env.CDT_SELENIUM_HOST || 'localhost';
const cdtServerHost = process.env.OPENSHIFT_NODEJS_IP || 'localhost';
const cdtServerPort = process.env.OPENSHIFT_NODEJS_PORT || 3040;const jasmineReporters = require('jasmine-reporters');
const util = require('util');///////////////////////////////////////////////////////////////////////////////exports.config = {  params: {
    env: process.env.CDT_PROTRACTOR_ENV || 'local'
  },  noColors: process.env.PROTRACTOR_NO_COLORS === 'yes',
  chromeDriver: '/usr/bin/google-chrome',  onPrepare: function () {    global.projectRoot = String(__dirname);
    let env = jasmine.getEnv();
    env.clearReporters();
    env.addReporter(new jasmineReporters.TapReporter());
  },  jasmineNodeOpts: {
    noColors: true,
    showColors: false, // process.env.PROTRACTOR_NO_COLORS !== 'yes',
    defaultTimeoutInterval: 15000,
  },  seleniumAddress: `http://${seleniumHost}:4444/wd/hub`,  multiCapabilities: [    {
      browserName: 'firefox',
      firefoxOptions: {
        args: ['-headless']
      }
    },    {
      browserName: 'chrome',
      chromeOptions: {
        binary: '/usr/bin/google-chrome',
        args: ['--headless']
      }
    }
  ],  specs: [
    './test/e2e/**/*spec.js',
  ]
};

Что меня смущает, так это почему Firefox будет работать в нашем контейнере Docker без особых усилий по настройке, но Chrome не будет. Я не понимаю, зачем нам нужен драйвер Chrome для общения с Selenium-running-Chrome, а не драйвер Firefox для общения с Selenium-running-Firefox.

Ошибка Получение при запуске наших тестов с Docker на Jenkins выглядит следующим образом:

[20:14:35] I/launcher - Running 2 instances of WebDriver
[20:14:36] I/testLogger - 
------------------------------------[20:14:36] I/testLogger - [chrome #11] PID: 15
[chrome #11] Specs: /usr/local/cdt-tests/test/e2e/by-roles/itso/home-page/home-page-spec.js
[chrome #11] 
[chrome #11] (node:15) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[chrome #11] selenium host: cdt-selenium.cdt-net
[chrome #11] cdt server host: cdt-server.cdt-net
[chrome #11] cdt server port: 3040
[chrome #11] [20:14:35] I/hosted - Using the selenium server at http://cdt-selenium.cdt-net:4444/wd/hub
[chrome #11] 
[chrome #11] /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:546
[chrome #11]         throw new ctor(message);
[chrome #11]               ^
[chrome #11] WebDriverError: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
[chrome #11]     at Object.checkLegacyResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:546:15)
[chrome #11]     at parseHttpResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509:13)
[chrome #11]     at doSend.then.response (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:441:30)
[chrome #11]     at <anonymous>
[chrome #11]     at process._tickCallback (internal/process/next_tick.js:188:7)
[chrome #11] From: Task: WebDriver.createSession()
[chrome #11]     at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
[chrome #11]     at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/chrome.js:761:15)
[chrome #11]     at createDriver (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:170:33)
[chrome #11]     at Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:626:16)
[chrome #11]     at Hosted.getNewDriver (/usr/local/lib/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
[chrome #11]     at Runner.createBrowser (/usr/local/lib/node_modules/protractor/built/runner.js:195:43)
[chrome #11]     at q.then.then (/usr/local/lib/node_modules/protractor/built/runner.js:339:29)
[chrome #11]     at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:834:54)
[chrome #11]     at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:863:30)
[chrome #11]     at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:796:13)[20:14:36] I/testLogger - [20:14:36] E/launcher - Runner process exited unexpectedly with error code: 1
[20:14:36] I/launcher - 1 instance(s) of WebDriver still running
.[20:15:00] I/testLogger - 
------------------------------------[20:15:00] I/testLogger - [firefox #01] PID: 14
[firefox #01] Specs: /usr/local/cdt-tests/test/e2e/by-roles/itso/home-page/home-page-spec.js
[firefox #01] 
[firefox #01] (node:14) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[firefox #01] selenium host: cdt-selenium.cdt-net
[firefox #01] cdt server host: cdt-server.cdt-net
[firefox #01] cdt server port: 3040
[firefox #01] [20:14:35] I/hosted - Using the selenium server at http://cdt-selenium.cdt-net:4444/wd/hub
[firefox #01] Started
[firefox #01] .
[firefox #01] 
[firefox #01] 
[firefox #01] 1 spec, 0 failures
[firefox #01] Finished in 21.585 seconds
[firefox #01] 

Как вы можете видеть, Firefox прошел, но Chrome не с этой ошибкой:

   [chrome #11]         throw new ctor(message);
    [chrome #11]               ^
    [chrome #11] WebDriverError: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html

0 ответов