Belen与Selenium Hub和Firefox错误:无法打开连接:从webdriver接收的有效负载是有效但意外的json

时间:2017-12-01 22:20:02

标签: selenium firefox docker selenium-grid behat

我尝试使用selenium/hubselenium/node-chrome-debugselenium/node-firefox-debug图像在Docker上运行Behat。

使用Chrome节点运行Behat工作正常,但Firefox节点给出了以下错误:

Could not open connection: Payload received from webdriver is valid but unexpected json: {"value":{"sessionId":"244f4715-c59b-4bfc-aa17-8f6a867ead83","capabilities":{"moz:profile":"/tmp/rust_mozprofile.u3mB4xKf6nVD","rotatable":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"pageLoadStrategy":"normal","moz:headless":false,"moz:accessibilityChecks":false,"acceptInsecureCerts":false,"browserVersion":"57.0","platformVersion":"4.9.60-linuxkit-aufs","moz:processID":1005,"browserName":"firefox","platformName":"linux","moz:webdriverClick":false}}} (Behat\Mink\Exception\DriverException)

当我vnc到Firefox节点时,我看到它打开了Firefox,但没有发生任何事情。

我的docker-compose.yml

version: '3.2'

services:
  site.local:
    image: webdevops/php-apache-dev:7.1
    ports:
      - "8888:80"
    volumes:
      - ./public:/app
      - .:/application

  selenium-grid-hub.local:
    image: selenium/hub
    ports:
      - "4445:4444"

  selenium-node-chrome.local:
    image: selenium/node-chrome-debug
    environment:
      - HUB_PORT_4444_TCP_ADDR=selenium-grid-hub.local
      - HUB_PORT_4444_TCP_PORT=4444
    ports:
      - "5901:5900"

  selenium-node-firefox.local:
    image: selenium/node-firefox-debug
    environment:
      - HUB_PORT_4444_TCP_ADDR=selenium-grid-hub.local
      - HUB_PORT_4444_TCP_PORT=4444
    ports:
      - "5902:5900"

我的behat.yml

default:
  extensions:
    Behat\MinkExtension:
      base_url: "http://site.local"
      goutte:
        guzzle_parameters:
          verify: false
  suites:
    mysuite:
      paths:    [ %paths.base%/features ]
      contexts:
        - Zstate\BehatSeleniumDockerSkeleton\Tests\Behat\Context\FeatureContext

chrome:
  extensions:
    Behat\MinkExtension:
      selenium2:
        browser: "chrome"
        wd_host: http://selenium-grid-hub.local:4444/wd/hub
        capabilities: {"browserName": "chrome", "browser": "chrome", 'chrome': {'switches':['--no-sandbox']}}

firefox:
  extensions:
    Behat\MinkExtension:
      selenium2:
        browser: "firefox"
        wd_host: http://selenium-grid-hub.local:4444/wd/hub
        capabilities: {"browserName": "firefox", "browser": "firefox"}

我创建了这个小repo来复制问题。

我非常感谢任何帮助或建议。如果我错过了我的问题,请告诉我,以便我可以更新。

1 个答案:

答案 0 :(得分:0)

万一有人有同样的错误,这就是对我的帮助。 就我而言,解决方法是建立以下内容:

对于Chrome:

$rootScope.addUser = function(userId) {        //1
            $http.post('/addUser', {           //2
                params: {                      //3
                    user_id: userId            //4
                }
            }).then(function(result) {         //5
                $rootScope.userId = undefined; //6
                $rootScope.getUsers();         //7
            });
        };

更多信息here