Adrian Krebs
Adrian Krebs

Reputation: 4387

How to set correct Selenium host for nightwatch e2e test on gitlab?

I would like to add some e2e tests for my vue.js application and run them in the pipeline. The corresponding part in my gitlab-ci.yml looks like this:

e2e:
image: node:8
before_script:
  - npm install
services:
  - name: selenium/standalone-chrome
  alias: chrome
stage: testing
script:
  - cd online-leasing-frontend
  - npm install
  - npm run test:e2e

And my nightwatch.js config:

{
  "selenium": {
    "start_process": false
    },
  "test_settings": {
    "default": {
      "selenium_port": 4444,
      "selenium_host": "chrome"
    }
  }
}

Is “selenium_host”: “chrome” the correct way of setting the host to the selenium service? I get the following error indicating that my e2e test can’t connect to the selenium service:

Connection refused! Is selenium server started?

Any tips?

Upvotes: 1

Views: 1295

Answers (2)

Adrian Krebs
Adrian Krebs

Reputation: 4387

The problem was that according to this issue, Gitlab CI is using the Kubernetes Executor instead of the Docker Executor which is mapping all Services to 127.0.0.1. After setting the selenium_host to this address, everything worked.

{
  "selenium": {
    "start_process": false
    },
  "test_settings": {
    "default": {
      "selenium_port": 4444,
       "selenium_host": "127.0.0.1",
    }
  }
}

Upvotes: 1

mibemerami
mibemerami

Reputation: 61

On the Selenium Repo it says: "When executing docker run for an image with Chrome or Firefox please either mount -v /dev/shm:/dev/shm or use the flag --shm-size=2g to use the host's shared memory." I don't know gitlab-ci so well, but I'm afraid it is not possible to add this as parameter to a service.

Upvotes: 0

Related Questions