skip to Main Content

Using Laravel 5+ with Vagrant.

I have selenium running using:

java -jar vendor/se/selenium-server-standalone/bin/selenium-server-standalone.jar -Dwebdriver.firefox.bin="/usr/bin/firefox"

using a headless display:

sudo Xvfb :10 -ac

However when i run codeception:

 ./vendor/bin/codecept run selenium --steps

I get the following error:

[FacebookWebDriverExceptionUnknownServerException] Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: GDK_BACKEND does not match available displays

I am confused with server and ports that i should be using.
Currently i access site through http://localhost:8000
however that is outside vagrant.

I observe $url = 'http://localhost:4444/wd/hub', inside apivendorfacebookwebdriverlibRemoteRemoteWebDriver.php

As the error outputs :

127.0.0.1 on port 7055.

2

Answers


  1. Chosen as BEST ANSWER

    Switched to chrome web driver, was less complicated, more compatible and works fine for me.

    1. Download chrome webdriver or composer require
    2. Setup environment

      nohup sudo Xvfb :10 -ac &

      export DISPLAY=:10

      java -jar vendor/se/selenium-server-standalone/bin/selenium-server-standalone.jar -Dwebdriver.chrome.bin="/usr/bin/google-chrome" -Dwebdriver.chrome.driver="vendor/bin/chromedriver"


  2. Actually you should download latest geckodriver from here and set property Dwebdriver.gecko.driver with downloaded geckodriver path from your system when you run the selenium-server-standalone.jar as below :

    java -jar vendor/se/selenium-server-standalone/bin/selenium-server-standalone.jar -Dwebdriver.firefox.bin="/usr/bin/firefox" -Dwebdriver.gecko.driver = "path/to/downloaded geckodriver 
    

    Note : Just like the other drivers available to Selenium from other browser vendors, Mozilla has released an executable geckodriver that will run alongside with the latest firefox browser. For more information you should follow this link.

    Now you need to set capability with marionette to true during initialisation of RemoteWebDriver inside apivendorfacebookwebdriverlibRemoteRemoteWebDriver.php as :

    $capabilities->setCapability('marionette', true);
    

    Full example code :

    $host = 'http://localhost:4444/wd/hub';
    $capabilities = DesiredCapabilities::firefox();
    $capabilities->setCapability('marionette', true);
    $driver = RemoteWebDriver::create($host, $capabilities, 5000);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search