Since documentation on GitLab CI configuration and Selenium is generally poor, I'm asking for help.
Configuration as by interest point:
gitlab.ci.yml
:
image: node:7
variables:
HUB_PORT_4444_TCP_ADDR: "selenium__hub"
HUB_PORT_4444_TCP_PORT: "4444"
services:
- selenium/hub:latest
- selenium/node-phantomjs:latest
stages:
- test
test:
stage: test
before_script:
- apt-get update
- apt-get install -y default-jdk default-jre
- npm install -s -g @angular/[email protected]
- npm install -s
- node ./node_modules/protractor/bin/webdriver-manager update
script:
- ./node_modules/.bin/protractor protractor.ci.conf.js
protractor.ci.conf.js
:
/*global jasmine */
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'phantomjs',
'phantomjs.binary.path': './node_modules/phantomjs-prebuilt/bin/phantomjs'
},
directConnect: false,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
onPrepare: function() {
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
},
seleniumAddress: 'http://selenium__hub:4444/wd/hub'
};
With the above configuration, GitLab fails with:
$ ./node_modules/.bin/protractor protractor.ci.conf.js
(node:3702) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[09:53:27] I/launcher - Running 1 instances of WebDriver
[09:53:27] I/hosted - Using the selenium server at http://selenium__hub:4444/wd/hub
[09:53:28] E/launcher - Error forwarding the new session Empty pool of VM for setup Capabilities [{phantomjs.binary.path=./node_modules/phantomjs-prebuilt/bin/phantomjs, count=1, browserName=phantomjs}]
[09:53:28] E/launcher - WebDriverError: Error forwarding the new session Empty pool of VM for setup Capabilities [{phantomjs.binary.path=./node_modules/phantomjs-prebuilt/bin/phantomjs, count=1, browserName=phantomjs}]
at Object.checkLegacyResponse (/builds/netaachen/operator-app/node_modules/selenium-webdriver/lib/error.js:505:15)
at parseHttpResponse (/builds/netaachen/operator-app/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/builds/netaachen/operator-app/node_modules/selenium-webdriver/lib/http.js:440:13)
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebDriver.createSession()
at Function.createSession (/builds/netaachen/operator-app/node_modules/selenium-webdriver/lib/webdriver.js:777:24)
at createDriver (/builds/netaachen/operator-app/node_modules/selenium-webdriver/index.js:167:33)
at Builder.build (/builds/netaachen/operator-app/node_modules/selenium-webdriver/index.js:632:14)
at Hosted.getNewDriver (/builds/netaachen/operator-app/node_modules/protractor/lib/driverProviders/driverProvider.ts:60:29)
at Runner.createBrowser (/builds/netaachen/operator-app/node_modules/protractor/lib/runner.ts:225:39)
at q.then.then (/builds/netaachen/operator-app/node_modules/protractor/lib/runner.ts:391:27)
at _fulfilled (/builds/netaachen/operator-app/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/builds/netaachen/operator-app/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/builds/netaachen/operator-app/node_modules/protractor/node_modules/q/q.js:796:13)
at /builds/netaachen/operator-app/node_modules/protractor/node_modules/q/q.js:556:49
[09:53:28] E/launcher - Process exited with error code 199
ERROR: Build failed: exit code 1
protractor - Could not find Angular on page http://selenium__standalone-chrome:4444/ : retries looking for angular exceeded
. The problem does not relate to the page not having angular since e2e tests pass locally with the local protactor configuration (baseUrl
set to localhost:4200). – Vocalise