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:
[Facebook\WebDriver\Exception\UnknownServerException] 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 api\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php
As the error outputs :
127.0.0.1 on port 7055.
Selenium IDE is an integrated development environment for Selenium tests. It is implemented as a Firefox extension, and allows you to record, edit, and debug tests.
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 api\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.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);
Switched to chrome web driver, was less complicated, more compatible and works fine for me.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With