【问题标题】:Running dockerized Behat BDD Tests using Zalenium ( scalable selenium grid )使用 Zalenium(可扩展的硒网格)运行 dockerized Behat BDD 测试
【发布时间】:2019-07-23 06:17:08
【问题描述】:

我正在尝试使用 docksal/behat docker-compose 运行 Behat 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 应该指向容器中运行的硒网格?

【问题讨论】:

    标签: selenium docker-compose behat zalenium


    【解决方案1】:

    这个

    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

    【讨论】:

    • 如果我删除 elgalu/selenium:我无法启动 zalenium 集群,查看。错误日志:$ docker logs zalenium Docker 版本 18.09.0,构建 4d60db4 -- LOG 10:54:23:171273933 确保 docker 工作... -- LOG 10:54:23:246228848 确保 docker-selenium 可用...好像docker-selenium的镜像还没有拉出来请运行'docker pull elgalu/selenium',或者通过--seleniumImageName使用自己兼容的镜像
    • 您可以使用环境变量PULL_SELENIUM_IMAGE=true 来避免声明elgalu\selenium 服务的需要。
    • 我现在一直收到以下错误:无法完成 AJAX 请求。 (RuntimeException) 当我运行 Behat 测试时
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-05
    • 2013-07-29
    • 2018-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多