Is selenium 3.12 and geckodrvier 0.21.0 are compatible and stable, all tests gets skipped on linux machine

Viewed 748

Platform details:

geckodriver 0.21.0 , Firefox: 60, Selenium: 3.12, cent Os 7

When i ran it using mvn it starts successfully:

geckodriver INFO Listening on 127.0.0.1:14185

Marionette INFO Listening on port 284135

Tests run successfully on windows machine however when running the same on CentOs 7, tests gets skipped.

I observed All tests get skipped as the GUI of Firefox gets closed after some time with below info and error on cmd console:

INFO: org.openqa.selenium.WebDriverException: java.io.IOException: unexpected end of stream on Connection{localhost:33365, proxy=DIRECT hostAddress=localhost/12 6.10.0.1:258107

[ERROR] java.net.ConnectException: Failed to connect to localhost/127.0.0.1:2285

/bin/sh: line 1: 8780 Killed /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre/bin/java

if(platform.equalsIgnoreCase("linux")) {
FirefoxOptions options = new FirefoxOptions();
DesiredCapabilities desiredCap = DesiredCapabilities.firefox();
profile.setPreference("browser.download.dir",System.getProperty("user.dir")+ File.separator + "target");
System.setProperty("webdriver.gecko.driver", "/path/geckodriver/geckodriver");
System.setProperty("webdriver.firefox.bin","/usr/bin/firefox/firefox");
desiredCap.setCapability(CapabilityType.PLATFORM_NAME,Platform.LINUX);
desiredCap.setCapability("webdriver.firefox.profile",DesiredCapabilities.firefox());
driver = new FirefoxDriver();
}

I have spent so much time on this but unable to find the root cause of this. Using maven surefire plugin 2.19.1.

Kindly help me on this i am really stuck here.

2 Answers

As per the documentation below the combination of the binaries which you have mentioned in your question (Selenium v3.12 / GeckoDriver v0.21.0 / Firefox v60) are compatible and stable as follows:

Geckodriver Releases

This error message...

INFO: org.openqa.selenium.WebDriverException: java.io.IOException: unexpected end of stream on Connection{localhost:33365, proxy=DIRECT hostAddress=localhost/12 6.10.0.1:258107
[ERROR] java.net.ConnectException: Failed to connect to localhost/127.0.0.1:2285

...implies that the GeckoDriver was unable to initiate/spawn a new WebBrowser i.e. Firefox Browser session.

As you have mentioned about using GeckoDriver v0.21.0 there is no need to mention the setProperty with webdriver.firefox.bin. You need to ensure that Mozilla Firefox is installed at the default location for each system.

Solution

  • As per your code trials though you have created and configured the FirefoxOptions Class and DesiredCapabilities Class objects, you havn't passed them during initializing the WebDriver.
  • If your usecase requires the FirefoxOptions Class and DesiredCapabilities Class objects you need to pass them during initializing the WebDriver and Web Browser.
  • If your usecase does not requires the FirefoxOptions Class and DesiredCapabilities Class objects you need to remove them.

Your code looks fine to me.

Check for all the processes being used in your automation, make sure multiple processes are not running. Most importantly for following:

ps -ef|grep firefox

ps -ef|grep geckodriver

ps -ef|grep java 

Close if multiple process are running

Check for any error logs:

sudo vi /var/log/messages

Find for Kill or ERROR.This should help where it is breaking.

Related