php - docker-compose 中的代码接收 - 无法连接到 Webdriver

标签 php nginx docker-compose selenium-chromedriver codeception

我在为我的代码接收设置 Webdriver 时出现错误,只是无法弄清楚。

当开始时

docker-compose run --rm codeception run

它找到验收测试,甚至读取 $I->wantTo
但随后抛出错误:
[ConnectionException] Can't connect to Webdriver at http://127.0.0.1:4444/wd/hub. Please make sure that Selenium Server or PhantomJS is running.

我的 acceptance.suite.yml是以下内容,我已经尝试用 chrome、nginx-web、实际服务器的 ip 替换 url(这没有意义,但我真的不知道还能在那里放什么)
actor: AcceptanceTester
modules:
    enabled:
        # selenium webdriver
        - WebDriver:
            url: 'http://localhost/'
            browser: chrome

        - \Helper\Acceptance

我的 docker-compose.yml .我在附加覆盖中设置了音量
version: '2'
services:

  codeception:
    image: codeception/codeception:2.3.5
    depends_on:
      - nginx-web
      - php-web
      - chrome

  nginx-web:
    image:
      nginxext:0.5.6
    depends_on:
      - php-web
    expose:
      - 80

  php-web:
    image:
      phpext:0.7.0
    expose:
      - 9000

  # https://github.com/SeleniumHQ/docker-selenium
  chrome:
    image: selenium/standalone-chrome-debug:3.7.1
    ports:
      - 4444
      - 5900

任何想法我做错了什么?

最佳答案

我终于找到了。鉴于网络上仅使用 url 的各种描述,我认为我也在使用 url 设置主机。但是您实际上需要独立设置主机和网址。所以解决办法就是把selenium浏览器的服务名和host一起加进去。

        - WebDriver:
            url: http://localhost/      # url of app
            browser: chrome
            host: chrome                # selenium server host, default 127.0.0.1
#            port: 4444                 # selenium server port, default 4444
#            window_size: maximize      # or 640x480

关于php - docker-compose 中的代码接收 - 无法连接到 Webdriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47561478/

相关文章:

nginx - 由对等方重置连接)同时代理升级的连接和连接到上游时连接被拒绝

mysql - Docker Compose mysql 导入 .sql

linux - 同一台机器上的两个版本的 Docker 数据卷?

php - 在自定义 foreach 循环中按字母顺序对结果进行排序

javascript - 显示多组按钮中的当前按钮

linux - 程序接收信号SIGIO

ruby-on-rails - 如何通过 ESI :include, 设置 Cookie?

php - 在 php 中将当前月份拆分为数周

php - 构建一个按钮,显示它在 WORDPRESS 中被点击的次数

java - Web容器无法从docker compose调用后端容器