Search code examples
seleniumbehatmink

Could not open connection: Undefined index: status (selenoid, behat, mink)


I am trying to switch from selenium to aerokube/selenoid. Selenium following setup works:

version: '2.1'
services:

  hub:
    image: selenium/hub:2.53.0
    ports:
      - "4444:4444"
    networks:
      - default

  browser0:
    image: selenium/node-firefox-debug:2.53.0
    ports:
      - "5555"
    environment:
      SE_OPTS: '-log $PWD/logs/selenium-logs'
    networks:
      - default
    depends_on:
        - hub
    environment:
      - HUB_PORT_4444_TCP_ADDR=hub
      - HUB_PORT_4444_TCP_PORT=4444
      - no_proxy=localhost

I try following selenoid setup:

version: '3'
services:

  selenoid:
    image: selenoid/vnc:firefox_53.0
    network_mode: bridge
    ports:
      - "4444:4444"
    volumes:
      - ".:/etc/selenoid"
      - "/var/run/docker.sock:/var/run/docker.sock"

  selenoid-ui:
    image: aerokube/selenoid-ui
    network_mode: bridge
    links:
      - selenoid
    ports:
      - "8080:8080"
    command: ["--selenoid-uri", "http://selenoid:4444"]

It fails with Could not open connection: Notice: Undefined index: status in /ProjectPath/vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php line 139 (Behat\Mink\Exception\DriverException)

the source code there is the following:

// if not success, throw exception
    if ((int) $result['status'] !== 0) {
        throw WebDriverException::factory($result['status'], $message);
    }

When I var_dump($result);die;:

array(1) {   ["value"]=>   array(2) {
    ["sessionId"]=>
    string(36) "20c829fa-7f73-45a5-b440-8a3282b4feea"
    ["capabilities"]=>
    array(12) {
      ["acceptInsecureCerts"]=>
      bool(false)
      ["browserName"]=>
      string(7) "firefox"
      ["browserVersion"]=>
      string(6) "55.0.1"
      ["moz:accessibilityChecks"]=>
      bool(false)
      ["moz:processID"]=>
      int(35)
      ["moz:profile"]=>
      string(33) "/tmp/rust_mozprofile.BdIIDrRL7KKu"
      ["pageLoadStrategy"]=>
      string(6) "normal"
      ["platformName"]=>
      string(5) "linux"
      ["platformVersion"]=>
      string(14) "3.16.0-4-amd64"
      ["rotatable"]=>
      bool(false)
      ["specificationLevel"]=>
      int(0)
      ["timeouts"]=>
      array(3) {
        ["implicit"]=>
        int(0)
        ["pageLoad"]=>
        int(300000)
        ["script"]=>
        int(30000)
      }
    }   } }

So it does something.
Not sure what is the problem, any help would be appreciated.

My dog loves to eat and go outside, does yours too? How do you find stackoverflow turned out to be so limiting and I have to write additional stuff except code, what is this?


Solution

  • This error should reproduce with latest Firefox versions only (e.g. 53.0, 54.0 or 55.0) - all the rest should work. This is because browser images for these versions are using direct proxying to Geckodriver which is following W3C Selenium protocol specification starting from release 0.16.0. This specification has a bit different JSON exchange format than previous Selenium versions supported. So in order to fix this issue you just need to update your PHP Selenium client to the latest version supporting new format. Not sure about concrete version but e.g. for Java it should work starting from version 3.4.0.