Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Docker E/runner-无法启动WebDriver会话_Docker_Selenium Webdriver_Docker Compose_Protractor_Selenium Chromedriver - Fatal编程技术网

Docker E/runner-无法启动WebDriver会话

Docker E/runner-无法启动WebDriver会话,docker,selenium-webdriver,docker-compose,protractor,selenium-chromedriver,Docker,Selenium Webdriver,Docker Compose,Protractor,Selenium Chromedriver,我创建了一个docker-compose.yml文件来运行一些存储在公共repo中的量角器测试。yml文件中创建了几个容器: 共享存储:克隆测试的地方 selenium hub:具有selenium映像的容器 chrome:带有selenium/node chrome调试的容器 量角器:带有节点的容器:12.14图像 Docker编写文件是: version: '2.4' services: shared_repo: image: library/postgres:13.2-a

我创建了一个docker-compose.yml文件来运行一些存储在公共repo中的量角器测试。yml文件中创建了几个容器:

  • 共享存储:克隆测试的地方
  • selenium hub:具有selenium映像的容器
  • chrome:带有selenium/node chrome调试的容器
  • 量角器:带有节点的容器:12.14图像
Docker编写文件是:

version: '2.4'
services:

  shared_repo:
    image: library/postgres:13.2-alpine
    container_name: shared_repo
    command: bash -c "apk add git && sleep 5s && git clone -b main https://github.com/AlfredoBazo/opwDocker.git && mv /opwDocker /shared_repository && echo "TEST" && sleep 100s"
    ports:
    - 1603:1603
    volumes:
    - shared_repository:/e2e-shared

  selenium-hub:
    image: selenium/hub
    container_name: selenium-hub
    ports:
    - "4444:4444"

  chrome:
    image: selenium/node-chrome-debug
    container_name: chrome
    volumes:
    - /dev/shm:/dev/shm
    ports:
    - "5900:5900"
    depends_on:
      - selenium-hub
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444
      - CHROME_DRIVER_VERSION=chromedriver_81.0.4044.69

  protractor:
    image: node:12.14
    container_name: protractor
    working_dir: /e2e/
    volumes:
      - .:/e2e
    ports:
    - "9229:9229"
    command: bash -c "npm install && npm i protractor && ./node_modules/protractor/bin/webdriver-manager update && ls -haltr && node node_modules/protractor/bin/protractor e2e/protractor.conf.js --cucumberOpts.tags=@docker"
    depends_on:
    - selenium-hub
    - chrome

volumes:
  shared_repository:
执行
docker compose up
时出现错误,提示:

[09:09:18]I/launcher-运行WebDriver量角器的1个实例
|[09:09:18]我/直接-直接使用ChromeDriver。。。量角器
|[09:09:18]E/runner-无法启动WebDriver会话。 量角器|[09:09:18]E/启动器-错误:错误:服务器 提前终止,状态为127量角器| at /e2e/node_modules/selenium webdriver/remote/index.js:252:52量角器 |在游行和拒绝时 (internal/process/task_queues.js:94:5)量角器|[09:09:18] E/启动器-进程退出,错误代码为100


这个项目有一些误解,但我认为主要的问题是您使用的是本地Webdriver,而不是您提出的SeleniumHub实例。我认为我们可以将docker-compose.yaml文件简化为:

version: '2.4'
services:

  selenium-hub:
    image: selenium/hub
    container_name: selenium-hub
    ports:
    - "4444:4444"

  chrome:
    image: selenium/node-chrome-debug
    container_name: chrome
    volumes:
    - /dev/shm:/dev/shm
    ports:
    - "5900:5900"
    depends_on:
      - selenium-hub
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444
      - CHROME_DRIVER_VERSION=chromedriver_81.0.4044.69

  protractor:
    image: node:12.14
    container_name: protractor
    ports:
    - "9229:9229"
    command: bash -c "apt update && apt install -y git && git clone -b main https://github.com/AlfredoBazo/opwDocker.git && cd opwDocker && npm install && node node_modules/protractor/bin/protractor e2e-tests/protractor.conf.js --cucumberOpts.tags=@docker"
    depends_on:
    - selenium-hub
    - chrome
您需要修改您的dragrator.conf.js,添加以下行:

seleniumAddress: 'http://selenium-hub:4444/wd/hub'
并删除下一个:

directConnect: true

无论如何,我将包括一些其他必要的更改,以使其在

中运行,有什么想法吗?我还没有解决它。