如何在gitlab上为夜视e2e测试设置正确的Selenium主机?

时间:2018-07-27 11:25:02

标签: selenium vue.js gitlab-ci nightwatch.js vue-cli

我想为我的vue.js应用程序添加一些e2e测试,并在管道中运行它们。 我的gitlab-ci.yml中的相应部分如下所示:

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

还有我的nightwatch.js配置:

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

“ selenium_host”:“ chrome”是否是将主机设置为硒服务的正确方法? 我收到以下错误消息,指示我的e2e测试无法连接到硒服务:

连接被拒绝!硒服务器启动了吗?

有什么提示吗?

2 个答案:

答案 0 :(得分:1)

问题是,根据this issue,Gitlab CI使用Kubernetes Executor而不是Docker Executor,后者将所有服务映射到127.0.0.1。将selenium_host设置为此地址后,一切正常。

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

答案 1 :(得分:0)

在硒仓库中说: “当使用Chrome或Firefox执行docker run映像时,请挂载-v / dev / shm:/ dev / shm或使用标志--shm-size = 2g来使用主机的共享内存。” 我不太了解gitlab-ci,但恐怕无法将其作为参数添加到服务中。

相关问题