在Docker中运行Webdriverio测试时找不到Chrome二进制文件

时间:2019-06-15 13:07:09

标签: javascript docker docker-compose dockerfile webdriver-io

我正在努力尝试在var id = $(this).attr("data-id") $.ajax({ type: "GET", url: "XTM307.aspx/GetPart?id=" + id, contentType: "application/json", dataType: "json", success: function (response) { } }); 中运行wdio测试,错误是它无法在当前设置下找到Docker

docker-compose.yml

Chrome binary

Dockerfile

version: "3.7"

services:
  code:
    image: my-image
    build:
        dockerfile: ./Dockerfile
        context: .
    volumes:
      - .:/app
    depends_on:
      - "selenium"
    command: /bin/bash -c "cd app; npm test"
  selenium:
      image: selenium/standalone-chrome
      volumes:
        - /dev/shm:/dev/shm
      ports:
        - "4444:4444"

wdio.conf.js

FROM node:10.15.3
ADD . /app
WORKDIR /app
RUN apt update && apt install default-jre -y

运行... exports.config = { runner: 'local', // host: process.env.HOST, host: 'selenium', port: 4444, ...

后出现错误
docker-compose up

1 个答案:

答案 0 :(得分:0)

必须按如下所示编辑docker-compose.yml:

version: "3.7"

services:
  code:
    network_mode: host
    image: my-image
    build:
        dockerfile: ./Dockerfile
        context: .
    volumes:
      - .:/app
    depends_on:
      - "selenium"
    command: /bin/bash -c "cd app; npm test"
  selenium:
      network_mode: host
      image: selenium/standalone-chrome:3.141.59-oxygen
      volumes:
        - /dev/shm:/dev/shm
    ```