1
votes

Code Snippet -

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxDriverLogLevel;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
public class SeleniumClientClass {
    public static void main(String[] args) {
        System.setProperty("webdriver.gecko.driver","D:\\YoutubeVideos\\Selenium\\geckodriver.exe");

/*      DesiredCapabilities capability = DesiredCapabilities.firefox();
        capability.setCapability("marionette", true); */

        try {
        FirefoxOptions opts = new FirefoxOptions().setLogLevel(FirefoxDriverLogLevel.TRACE);
        WebDriver driver = new FirefoxDriver(opts);
        driver.get("http://www.google.com");

        Thread.sleep(10);
        System.out.println("Application title is ============>>>>>>> "+driver.getTitle());
        driver.quit();
        } catch(Exception e) {
            System.out.println(e);
        }       
    }

}

Error I am getting:

org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:38558 Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:03.216Z' System info: host: 'MPL-CJ08HM2', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '9.0.4' Driver info: driver.version: FirefoxDriver

1

1 Answers

0
votes

I got this issue resolved by having latest version of geckodriver.exe (v0.20.1) as I was earlier using older version of geckodriver(v0.9.0)...