我无法启动Firefox。我使用的是Selenium 3.10.0,Firefox版本是0.19.1
代码:
public class SampleClass
{
public static void main(String[] args)
{
System.setProperty("webdriver.gecko.driver", "E:\\geckodriver-v0.19.1-win32\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.co.in/?gfe_rd=cr&dcr=0&ei=pvK5WsHVGKSIX7qArmA");
}
}
错误:
org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:20603
Build info: version: '3.10.0', revision: '176b4a9', time: '2018-03-02T19:10:56.039Z'
答案 0 :(得分:0)
许多错误是驱动程序和浏览器过时的结果。请确保您运行的是最新版本。
将您的GeckoDriver更新到最新版本:(应为v20) https://github.com/mozilla/geckodriver/releases/download/v0.20.0/geckodriver-v0.20.0-win32.zip
将您的Firefox更新到最新版本:(应为v59.0。*) https://www.mozilla.org/en-US/firefox/releases/
更新您的Selenium服务器:( Java - 应该是v3.11.0) https://www.seleniumhq.org/download/