Reputation: 11
import org.openqa.selenium.firefox.FirefoxDriver;
public class OpenBrowser {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver", "C:\\StudyPooja\\geckodriver.exe");
System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "C:\\StudyPooja\\Mylog.txt");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.facebook.com/");
Thread.sleep(5000);
}
}
The Error I'm getting is:
Exception in thread "main" org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:14170 Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:05:20.749Z' System info: host: 'D790-18', ip: '192.168.43.66', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_31' Driver info: driver.version: FirefoxDriver at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:130) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:125) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:103) at OpenBrowser.main(OpenBrowser.java:13) Caused by: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:14170 at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:242) at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:160)
Upvotes: 1
Views: 2531
Reputation: 193298
This error message...
Exception in thread "main" org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:14170
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:05:20.749Z'
System info: host: 'D790-18', ip: '192.168.43.66', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_31'
Driver info: driver.version: FirefoxDriver at
...implies that the GeckoDriver was unable to initiate/spawn a new Browsing Context i.e. Firefox Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
So there is a clear mismatch between the JDK v8u31 , Selenium Client v3.14.0.
Test
as a non-root user.driver.quit()
within tearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.Upvotes: 0