0

I have an e2e tests project in protractor (v7) with chrome set as the target browser in the config.ts

...
directConnect: true,
multiCapabilities: [
    {
      browserName: 'chrome',
      chromeOptions: {
        args: ["--headless", "--disable-gpu", "--window-size=1920x1080", "--no-sandbox"]
      }
    }
],
...

Running the project via gitlab-runner's shell executor with gitlab-runner exec shell run_tests works fine but if i run it via gitlab-runner's docker executor, with gitlab-runner exec docker run_tests, it crashes on the yarn test cmd (which basically translates to protractor config.ts) of the gitlab-ci script with the following logs:

protractor config.ts
[09:14:27] I/launcher - Running 1 instances of WebDriver
[09:14:27] I/direct - Using ChromeDriver directly...
[09:14:27] E/launcher - spawn /builds/project-0/node_modules/webdriver-manager/selenium/chromedriver_90.0.4430.24 ENOENT
[09:14:27] E/launcher - Error: spawn /builds/project-0/node_modules/webdriver-manager/selenium/chromedriver_90.0.4430.24 ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:249:19)
    at onErrorNT (internal/child_process.js:442:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:9)
[09:14:27] E/launcher - Process exited with error code 199
error Command failed with exit code 199.

The .gitlab-ci.yml looks like this:

image: node:12.2.0-alpine

stages:
  - run

variables:
  SERVER_URL: "https://xyz.io/login"
  USER_1_USERNAME: "rico"

run_tests:
  stage: run
  script:
    - echo $SERVER_URL
    - echo $USER_1_USERNAME
    - yarn install:deps
    - yarn test

Any help will be much appreciated. Am i missing chrome installation in the ci script ?

oomer
  • 159
  • 3
  • 13

1 Answers1

0

So, my hunch was right, it was basically missing google chrome installation and since i was using an alpine docker image, installing chrome was no simple feat either. So, i had to change my docker image to node:<version> which are debian based images and include chrome installation instructions, using info from https://askubuntu.com/a/196100/1217294, only excluding the sudos (they are not needed in a gitlab-runner container) and including and -y (to bypass user prompt) after apt-get install, and it worked. Here is how my gitlab ci script looks like:

image: node:12

stages:
  - run

run_tests:
  stage: run
  script:
    - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - 
    - sh -c 'echo "deb https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
    - apt-get update
    - apt-get install -y google-chrome-stable
    - yarn install:deps
    - yarn test
oomer
  • 159
  • 3
  • 13