0

Here's the situation: I'm using Behat to run acceptance tests on Symfony. To do so, I start a Selenium instance with the Geckodriver, then I run Behat. Everything works fine on local (great!).

But when it runs on Github action, it fails. I've check the versions, I've even versioned the geckodriver and selenium.jar files to use exactly the same (despite they already exist on github action), but nothing works.

So I'm looking for any help to debug this error. Here's the commands and their results:

$ java -jar -Dwebdriver.gecko.driver=/usr/local/share/gecko_driver /usr/share/java/selenium-server-standalone.jar &

14:19:46.106 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
14:19:46.369 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2020-05-29 14:19:46.780:INFO::main: Logging initialized @1350ms to org.seleniumhq.jetty9.util.log.StdErrLog
14:19:47.657 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
14:19:47.758 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
./vendor/bin/behat -s acceptance

Could not open connection: Unable to create new service: GeckoDriverService
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'fv-az33', ip: '10.1.0.4', os.name: 'Linux', os.arch: 'amd64', os.version: '5.3.0-1022-azure', java.version: '1.8.0_252'
Driver info: driver.version: unknown (Behat\Mink\Exception\DriverException)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Fur Nocte
  • 43
  • 7

2 Answers2

0

This error message...

Driver info: driver.version: unknown (Behat\Mink\Exception\DriverException)

...implies that the GeckoDriver wasn't recognized back by the Browsing Context i.e. Firefox browser.


Solution

Ensure that:

  • JDK is upgraded to current levels JDK 8u251.
  • Selenium is upgraded to current levels Version 3.141.59.
  • GeckoDriver is upgraded to GeckoDriver v0.26.0 level.
  • Firefox is upgraded to current Firefox v76.0 levels.
  • GeckoDriver is present in the desired location.
  • GeckoDriver is having executable permission for non-root users.
  • If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your Test as a non-root user.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Reference

You can find a couple of relevant discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Yep, I've already checked all the versions and everything is alright. The for the locations and permissions. As the error is on Github Action, I do not have to check for system reboot nor used user. And I'm using behat, so I guess it's this package which is supposed to call those methods. – Fur Nocte Jun 01 '20 at 11:32
0

Ok, I've just solved my problem. I think this is due to two things:

  • First, I was not using the headless mode. I don't know to set it using Geckodriver because I'm finally using Chromedriver
  • Second, the github action's doc is misleading. It says 'Chrome Driver is available via CHROMEWEBDRIVER environment variable', but in fact it's only the directory which is in the env var. So the path of the driver is $CHROMEWEBDRIVER/chromedriver (same for $GECKOWEBDRIVER)

For info, here's my config of behat:

javascript_session:
  selenium2:
  browser: chrome
  capabilities:
    chrome:
      switches:
        - "--headless"
        - "--disable-gpu"

And to run Selenium:

java -Dwebdriver.chrome.driver=$CHROMEWEBDRIVER/chromedriver -jar $SELENIUM_JAR_PATH &
Fur Nocte
  • 43
  • 7