How to launch mozilla firefox using webDriver | Selenium Forum
M
Posted on 26/08/2016
I have downloaded the 32-bit version of geckodriver.exe and have written the following code in the .java file

System.setProperty("webdriver.gecko.driver","D:\\geckodriver.exe");
FirefoxDriver fd = new FirefoxDriver();
fd.get("http://bbc.com");
System.out.println("Application title is ============="+fd.getTitle());

I am getting the below error.Please help to launch Firefox...Thank you.

Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: 'unknown', revision: '2aa21c1', time: '2016-08-02 14:59:43 -0700'
System info: host: 'OWNER-PC', ip: '192.168.1.100', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_101'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:670)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:232)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:220)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:215)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:124)
at Drivers.main(Drivers.java:13)
Caused by: org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:31963 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
Build info: version: 'unknown', revision: '2aa21c1', time: '2016-08-02 14:59:43 -0700'
System info: host: 'OWNER-PC', ip: '192.168.1.100', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_101'
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:649)
... 8 more
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:31963 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:158)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:142)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:88)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
... 9 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:74)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:141)
... 22 more

M
Replied on 27/08/2016

are you still having the problem?


M
Replied on 27/08/2016

yes it is still giving me "UnreachableBrowserException" with Mozilla though the same code works fine with chrome and IE.


M
Replied on 28/08/2016

what is the Firefox version are you using?


M
Replied on 17/12/2016

[quote="qtpselenium.supp0rt@gmail.com":wq0zqqkq]what is the Firefox version are you using?[/quote:wq0zqqkq]

I am getting same error here.

I am using FF version 50.1.0 and selenium version selenium-java-3.0.1.

can you please guide me how can I proceed ?

Regards,
Sumanta


M
Replied on 18/12/2016

are you using gecko driver?

selenium 3 requires gecko driver.


M
Replied on 18/12/2016

yes, I am using geckodriver.exe


M
Replied on 18/12/2016

try a different version of FF. try first with FF47.


M
Replied on 19/12/2016

Below code working fine in FF 47 and Latest Selenium (3.0.1)

public class launchFF {

public static void main(String[] args) {






System.setProperty("webdriver.firefox.marionette","E:\\geckodriver.exe");
(Please note system property should change to above)
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);

WebDriver driver = new FirefoxDriver();

driver.get("http://www.youtube.com");

System.out.println("Made it to the promised land");

driver.quit();

}

}

However I have tried FF 49 and FF 50 with Latest Selenium but I am getting same error.


M
Replied on 19/12/2016

use FF47 then.selenium works with a older version of firefox. we have explained this in video.