在高山docker容器上运行硒测试时出错

时间:2019-01-14 12:23:40

标签: docker selenium-webdriver chromium acceptance-testing alpine

Dockerfile:

FROM node:8.14.1-alpine

RUN apk update && apk add --no-cache openjdk8-jre
RUN apk update && apk add python py-pip curl unzip libexif udev nano

ENV CHROME_BIN=/usr/bin/chromium-browser
RUN echo @v3.8 http://nl.alpinelinux.org/alpine/v3.8/community >> /etc/apk/repositories && \
    echo @v3.8 http://nl.alpinelinux.org/alpine/v3.8/main >> /etc/apk/repositories && \
    apk add --no-cache \
    chromium@v3.8 \
    nss@v3.8

# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true

WORKDIR /project_compile/vue_app

COPY vue_app /project_compile/vue_app
RUN rm -rf node_modules

RUN npm config set registry http://registry.npmjs.org/ && npm install

CMD npm run test:e2e:headless

运行时,会发生此错误:

Error retrieving a new session from the selenium server

Connection refused! Is selenium server started?
{ value: 
   { message: 'Timed out waiting for driver server to start.\nBuild info: version: \'3.141.59\', revision: \'e82be7d358\', time: \'2018-11-14T08:25:53\'\nSystem info: host: \'a3f993cb3a2b\', ip: \'172.22.0.2\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'4.15.0-33-generic\', java.version: \'1.8.0_191\'\nDriver info: driver.version: unknown',
     error: 'unknown error' },
  status: 13 }

 ERROR  Error: Command failed: /project_compile/vue_app/node_modules/nightwatch/bin/nightwatch --config nightwatch.conf.js --env chrome
Error: Command failed: /project_compile/vue_app/node_modules/nightwatch/bin/nightwatch --config nightwatch.conf.js --env chrome
    at makeError (/project_compile/vue_app/node_modules/execa/index.js:174:9)
    at Promise.all.then.arr (/project_compile/vue_app/node_modules/execa/index.js:278:16)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue_app@0.1.0 test:e2e:headless: `vue-cli-service test:e2e --config nightwatch.conf.js --env chrome`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the vue_app@0.1.0 test:e2e:headless script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-01-14T12_14_57_744Z-debug.log

似乎铬能正常工作(可测试运行诸如铬浏览器--headless --no-sandbox --dump-dom https://www.chromestatus.com/之类的东西),硒似乎也能正常工作。

为什么测试不运行?该错误无法解释。

所有代码都包含在此仓库https://github.com/nicolalandro/vue-selenium-docker中。因此,复制很容易-克隆存储库并运行两个命令:

  • docker-compose -f docker / test / js / docker-compose-js-e2e.yml build
  • docker-compose -f docker / test / js / docker-compose-js-e2e.yml up --exit-code-from e2e

2 个答案:

答案 0 :(得分:0)

也许您必须等待硒容器装满吗?

查看此指南: https://github.com/SeleniumHQ/docker-selenium#waiting-for-the-grid-to-be-ready

编写脚本以检查“就绪”:是

答案 1 :(得分:0)

问题是硒版本与chrome版本不匹配。