无法在Eclipse Oxygen上设置Selenium 3

时间:2018-06-13 10:44:59

标签: java eclipse selenium-webdriver gecko

代码段 -

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);
        }       
    }

}

我收到错误:

  

org.openqa.selenium.WebDriverException:   java.net.ConnectException:无法连接   localhost / 127.0.0.1:38558构建信息:版本:' 3.12.0',修订版:   ' 7c6e0b3',时间:' 2018-05-08T15:15:03.216Z'系统信息:主持人:   ' MPL-CJ08HM2',ip:' 192.168.56.1',os.name:' Windows 10',os.arch:   ' amd64',os.version:' 10.0',java.version:' 9.0.4'司机信息:   driver.version:FirefoxDriver

1 个答案:

答案 0 :(得分:0)

我通过使用最新版本的geckodriver.exe(v0.20.1)来解决此问题,因为我之前使用的是旧版geckodriver(v0.9.0)......