Getting WebDriver to work with Firefox

Using Laravel 5+ with Vagrant.

I have selenium 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 the code:

 ./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. Exit to the Firefox console: Error: GDK_BACKEND does not match the available displays

I am confused with the server and the ports that I have to use. I am currently accessing the site through http://localhost:8000 however it is outside the vagrants.

I watch $url = 'http://localhost:4444/wd/hub'insideapi\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php

How the error is output:

127.0.0.1 on port 7055.

+4
source share
2 answers

-, , .

  • -webdriver
  • 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 = "//chromedriver"

+3

geckodriver Dwebdriver.gecko.driver geckodriver selenium-server-standalone.jar :

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 

. , Selenium , Mozilla geckodriver, Firefox. .

marionette true RemoteWebDriver api\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php :

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

:

$host = 'http://localhost:4444/wd/hub';
$capabilities = DesiredCapabilities::firefox();
$capabilities->setCapability('marionette', true);
$driver = RemoteWebDriver::create($host, $capabilities, 5000);
+3

Source: https://habr.com/ru/post/1650493/


All Articles