【问题标题】:selenium with behat : Unable to find provider for sessionselenium with behat:无法找到会话提供者
【发布时间】:2020-09-18 02:22:30
【问题描述】:

所以我试图在 docker 容器中配置 selenium,以便与 behat 一起使用,当我到达 http://localhost:4444/status 时,集线器的状态为 not ready :

{
  "value": {
    "ready": false,
    "message": "Selenium Grid not ready.",
    "nodes": [
      {
        "id": "f746de23-58e4-499d-85fd-9bad4f904488",
        "uri": "http:\u002f\u002f172.22.0.5:5555",
        "maxSessions": 2,
        "stereotypes": [
          {
            "capabilities": {
              "browserName": "chrome"
            },
            "count": 2
          }
        ],
        "sessions": [
        ]
      }
    ]
  }
}

当我运行测试时:

Could not open connection: Payload received from webdriver is valid but unexpected json: {
        "value": {
          "error": "session not created",
          "message": "Unable to find provider for session: Capabilities {browser: firefox, browserName: chrome, ignoreZoomSetting: false, name: Behat feature suite, tags: [509f70556c1c, PHP 7.4.9]}, Capabilities {browserName: chrome}, Capabilities {browserName: firefox}, Capabilities {}\nBuild info: version: '4.0.0-alpha-7', revision: '117b9d61c9'\nSystem info: host: '7f39dcd595c7', ip: '172.22.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.19.76-linuxkit', java.version: '1.8.0_265'\nDriver info: driver.version: unknown",
          "stacktrace": "org.openqa.selenium.SessionNotCreatedException: Unable to find provider for session: Capabilities {browser: firefox, browserName: chrome, ignoreZoomSetting: false, name: Behat feature suite, tags: [509f70556c1c, PHP 7.4.9]}, Capabilities {browserName: chrome}, Capabilities {browserName: firefox}, Capabilities {}\nBuild info: version: '4.0.0-alpha-7', revision: '117b9d61c9'\nSystem info: host: '7 (Behat\Mink\Exception\DriverException)

我尝试了很多配置,主要是在 behat.yml 中的 wd_host 参数中,但我尝试的所有内容(不同的 url、不同的端口...)都给我带来了错误。

我的 docker-composer.yml:

version: '3'

services:
  chrome:
    image: selenium/node-chrome:4.0.0-alpha-7-prerelease-20200907
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - selenium-hub
    environment:
      - SE_EVENT_BUS_HOST=selenium-hub
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
    ports:
      - "6900:5900"

  selenium-hub:
    image: selenium/hub:4.0.0-alpha-7-prerelease-20200907
    container_name: selenium-hub
    ports:
      - "4442:4442"
      - "4443:4443"
      - "4444:4444"
    restart: always

我的 behat.yml:

extensions:
    Behat\MinkExtension:
        base_url: "http://localhost"
        browser_name: 'chrome'
        sessions:
            my_session:
                selenium2:
                    wd_host: "http://selenium-hub:4444"
                    browser: chrome
                    capabilities: { "browserName": "chrome"}
    FriendsOfBehat\SymfonyExtension: null

有一刻我以为它与“功能”参数有关,所以我尝试将东西放入其中,但它没有改变任何东西,我想如果只是这样,集线器仍然会告诉我它准备好了。

有什么想法吗?谢谢

【问题讨论】:

    标签: docker selenium symfony behat


    【解决方案1】:

    我使它与以前的版本一起使用 chrome selenium/node-chrome:3.141.59-oxygen 的图像。 我不得不为我的网络服务器的容器“url”更改 behat.yml 中的 base_url。 (http://nginx 是我的例子)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-31
      • 2018-12-21
      • 2016-02-14
      • 1970-01-01
      • 1970-01-01
      • 2019-04-24
      • 2014-08-07
      相关资源
      最近更新 更多