【发布时间】:2018-11-22 22:01:41
【问题描述】:
代码片段 -
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
【问题讨论】:
标签: java eclipse selenium-webdriver gecko