在docker-compose中运行webdriverIO

时间:2019-03-08 19:25:56

标签: docker docker-compose webdriver-io

我正在努力了解如何正确配置撰写文件以运行webdriverio。

我正在按照说明进行操作:

https://github.com/SeleniumHQ/docker-selenium/wiki/Getting-Started-with-Docker-Compose

在这里

https://github.com/blueimp/wdio/blob/master/docker-compose.yml

我主要是在努力了解我应该拥有哪些集线器以及什么取决于什么。欢迎任何输入

这是我的docker-compose文件

version: '3'
services:
    chromedriver:
        image: blueimp/chromedriver
        environment:
            - DISABLE_X11=false
            - ENABLE_VNC=true
            - EXPOSE_X11=true
        ports:
            - 127.0.0.1:7900:7900
    geckodriver:
        image: blueimp/geckodriver
        environment:
            - DISABLE_X11=false
            - ENABLE_VNC=true
            - EXPOSE_X11=true
        ports:
            - 127.0.0.1:6901:6900
    selenium:
        image: selenium/hub
        ports:
            - '14444:4444'
    firefox:
        image: selenium/node-firefox
        ports:
            - 5900
        environment:
            - HUB_PORT_4444_TCP_ADDR=selenium
        depends_on:
            - selenium
    chrome:
        image: selenium/node-chrome
        ports:
            - 5900
        environment:
            - HUB_PORT_4444_TCP_ADDR=selenium
        depends_on:
            - selenium
    my-app-selenium:
        build: .
        environment:
            SELENIUM_REMOTE_URL: 'http://selenium:4444/wd/hub'
            SELENIUM_APP_SUPER_URL: 'http://192.168.0.10:9000/super/'
            SELENIUM_APP_ADMIN_URL: 'http://192.168.0.10:9000/admin/'

这是我的Dockerfile

FROM node:carbon

RUN apt-get update && apt-get upgrade -y
WORKDIR /var/app/current
COPY package.json package-lock.json ./
RUN npm install

RUN apt-get update && \
  apt-get install -y openjdk-8-jdk && \
  apt-get install -y ant && \
  apt-get clean;

# Fix certificate issues
RUN apt-get update && \
  apt-get install ca-certificates-java && \
  apt-get clean && \
  update-ca-certificates -f;

# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME

COPY . .

CMD ./wait && npm run test

我在控制台中遇到的最后一个错误是

unknown error: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d),platform=Linux 4.15.0-46-generic x86_64) (WARNING: The server did not provide any stacktrace information)

Driver info: driver.version: unknown

wdio.conf.js

//to use debug option run `DEBUG=true followed by your .conf.js`
const defaultTimeoutInterval = process.env.DEBUG ? (60 * 60 * 500) : 90000;

exports.config = {
    hostname: 'selenium',
    port: 4444,
    specs: [
        './test/specs/*.js'
    ],
    exclude: [],
    maxInstances: 15,
    capabilities: [{
        maxInstances: 5,
        browserName: 'chrome'
    }, ],
    sync: false,
    logLevel: 'silent',
    deprecationWarnings: true,
    bail: 0,
    baseUrl: 'http://localhost:9000',
    waitforTimeout: 10000,
    connectionRetryTimeout: 90000,
    connectionRetryCount: 3,
    // services: ['docker'],
    framework: 'mocha',
    mochaOpts: {
        ui: 'bdd',
        timeout: 90000,
        compilers: ['js:@babel/register'],
    },
    reporters: [
        'spec',
        ['junit', {
            outputDir: './test/reports/junit-results/',
            outputFileFormat: function (opts) { // optional
                return `results-${opts.cid}.${opts.capabilities}.xml`
            }
        }],

        ['allure', {
            outputDir: './test/reports/allure-results/',
            disableWebdriverStepsReporting: true,
            disableWebdriverScreenshotsReporting: false,
        }],
    ],
    onPrepare: function (config, capabilities) {
        console.log('**** let\'s go ****');
    },
    beforeSession: function (config, capabilities, specs) {
        require('@babel/register');
    },
    before: function (capabilities, specs) {
        /**
         * Setup the Chai assertion framework
         */
        const chai = require('chai');
        global.expect = chai.expect;
        global.assert = chai.assert;
        global.should = chai.should();
    },
    afterTest: function (test) {
        //console.log(test);
    },
    onComplete: function (exitCode) {
        console.log('**** that\'s it ****');
    }
}

0 个答案:

没有答案