运行 使用 Zalenium(可扩展的 selenium 网格)进行 dockerized Behat BDD 测试

Running dockerized Behat BDD Tests using Zalenium ( scalable selenium grid )

我正在尝试 运行 使用 docksal/behat docker-compose 进行 BDD 测试(参考:https://github.com/docksal/behat

看 Zalenium documentation

Pull docker-selenium
    docker pull elgalu/selenium

# Pull Zalenium
docker pull dosel/zalenium

# Run it!
docker run --rm -ti --name zalenium -p 4444:4444 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /tmp/videos:/home/seluser/videos \
  --privileged dosel/zalenium start

# Point your tests to http://localhost:4444/wd/hub and run them

集成 docksal/behat 和 zelenium 不清楚

正在使用。这。关注 docker-compose.yml

# The purpose of this -test example is for the e2e tests of this project
#
# Usage:
#  docker-compose -p grid up --force-recreate
#  docker-compose -p grid scale mock=1 hub=1 chrome=3 firefox=3
version: '2.1'
services:
  hub:
    image: elgalu/selenium
    ports:
      - ${VNC_FROM_PORT-40650}-${VNC_TO_PORT-40700}:${VNC_FROM_PORT-40650}-${VNC_TO_PORT-40700}

  zalenium:
    image: "dosel/zalenium"
    container_name: zalenium
    hostname: zalenium
    tty: true
    volumes:
      - /tmp/videos:/home/seluser/videos
      - /var/run/docker.sock:/var/run/docker.sock
    privileged: true
    ports:
      - 4444:4444
    command: >
      start --desiredContainers 2
            --maxDockerSeleniumContainers 8
            --screenWidth 800 --screenHeight 600
            --timeZone "America/New_York"
            --videoRecordingEnabled false
            --sauceLabsEnabled false
            --browserStackEnabled false
            --testingBotEnabled false
            --cbtEnabled false
            --startTunnel false

  behat:
    hostname: behat
    image: docksal/behat
    volumes:
      - .:/src
    # Run a built-in web server for access to HTML reports
    ports:
     - 8000:8000
    entrypoint: "php -S 0.0.0.0:8000"

#  browser:
#    hostname: browser
    # Pick/uncomment one
#    image: selenium/standalone-chrome
    #image: selenium/standalone-firefox

我可以调出以下容器:

CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                                  NAMES
9a1620da4c71        elgalu/selenium:latest   "entry.sh"               4 seconds ago       Up 4 seconds        40001/tcp, 50001/tcp                   zalenium_52g9tn
82975a246be8        elgalu/selenium:latest   "entry.sh"               5 seconds ago       Up 4 seconds        40000/tcp, 50000/tcp                   zalenium_fdCCbk
862017957ba1        docksal/behat            "php -S 0.0.0.0:8000"    2 days ago          Up 8 seconds        0.0.0.0:8000->8000/tcp                 behat-selenium_behat_1
2da2c165a211        elgalu/selenium          "entry.sh"               4 days ago          Up 6 seconds        0.0.0.0:40650-40700->40650-40700/tcp   behat-selenium_hub_1
10df443d8378        dosel/zalenium           "entry.sh start --de…"   4 days ago          Up 8 seconds        0.0.0.0:4444->4444/tcp, 4445/tcp       zalenium

现在查看示例目录中的 run-behat

基本执行

$docker exec $(docker-compose ps -q behat) behat --colors --format=pretty --out=std --format=html --out=html_report "$@"

我得到一个错误:

Error response from daemon: Container 411c6b89d8f382a64ed567dbe4d02a2840f06d4778f1ce7bcf955e720d96ab02 is not running

鉴于:

$ docker-compose ps -q behat
411c6b89d8f382a64ed567dbe4d02a2840f06d4778f1ce7bcf955e720d96ab02

也许在 behat.yml wd_host: http://localhost:4444/wd/hub

它不应该指向本地主机,而是指向集线器?因为 wd_host 应该指向容器中的硒网格 运行?

这个

hub:
    image: elgalu/selenium
    ports:
      - ${VNC_FROM_PORT-40650}-${VNC_TO_PORT-40700}:${VNC_FROM_PORT-40650}-${VNC_TO_PORT-40700}

根本不需要。

只需将您的测试指向 zalenium 服务,因为您正在使用 docker-compose。 http://zalenium:4444/wd/hub