1
votes

I have tried with all version of Firefox 45, 48, 49, and 50. I also have to mention the path for the Gecko driver (64 bit) in my program, but still the Firefox browser is not opening once I run my program. I am using Selenium 3.0.1 Java version.

Here is my code:

System.setProperty("webdriver.gecko.driver", "C:\\Users\\Desktop\\ecpipse2\\Selenium Library files\\geckodriver.exe");
driver = new FirefoxDriver();
baseUrl = "http://automationpractice.com/index.php";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

The following error is coming:

org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:45120 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'LAPTOP-C07CIJJB', ip: '192.168.0.6', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_102' Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)

3

3 Answers

2
votes

If the Gecko driver version is not correct then it doesn't establish a connection with Firefox.

In the above question, the mentioned error was a little bit confusing which doesn't say about Gecko driver is not compatible with the Selenium web driver and Firefox version.

My case now: It's working fine with Firefox 49.0.2, Selenium webDriver 3.0.1, and Geckodriver.exe 0.11.1.

1
votes

You can see a working example here.

1
votes

The following combination worked fine for me:

Firefox: 50

selenium-java: 3.0.1

JUnit: 4.12

geckodriver.exe: 11.1