madhur madhur - 1 year ago 175
Java Question

Selenium test case script with Junit is not working on eclipse for Firefox driver

I have tried with all version of firefox 45, 48, 49 and 50. I also have to mention the path for gecko driver(64bit) in my program but still 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 = "";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

Following error is coming:

org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:45120 [localhost/, 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: '', '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(
at org.openqa.selenium.remote.RemoteWebDriver.execute(

Answer Source

If Gecko driver version is not correct then doesnt estabilish connection with above question , mentioned error was little bit confusing which doesn't say about Gecko driver is not compatible with selenium web driver and firefox version.My case now , its working fine with FF 49.0.2 , Selenium webDriver 3.0.1 and Geckodriver.exe 0.11.1

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download