【发布时间】:2018-04-22 12:15:05
【问题描述】:
我正在尝试在 Visual Studio 2017 中将 Selenium.WebDriver v3.7(来自 NuGet)、Firefox ESR v52.4.1(64 位)和 geckodriver v0.19.1 结合在一起。下面是我的 非常 em> 简单的测试控制台应用程序。
public class Program
{
public static void Main(string[] args)
{
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(@"C:\geckodriver\0.19.1");
service.FirefoxBinaryPath = @"C:\Program Files\Mozilla Firefox\firefox.exe";
IWebDriver driver = new FirefoxDriver(service);
driver.Navigate().GoToUrl("http://news.bbc.co.uk");
}
}
geckodriver 目录也添加到我的 Windows 10 PATH 系统环境变量中。
但是,FirefoxDriver 的实例化超时。下面是堆栈跟踪(审查了一些不相关的细节):
1510233068873 geckodriver INFO geckodriver 0.19.1
1510233068878 geckodriver INFO Listening on 127.0.0.1:65327
1510233070006 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:\\Users\\x\\AppData\\Local\\Temp\\rust_mozprofile.qt9HYniTrrCC"
Unhandled Exception: OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:65327/session timed out after 60 seconds. ---> System.Net.WebException: The request was aborted: The operation has timed out.
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
--- End of inner exception stack trace ---
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxDriverService service)
at Selenium3Stuff.Program.Main(String[] args) in c:\users\x\source\repos\Selenium3Stuff\Selenium3Stuff\Program.cs:line 12
谁能帮我理解发生了什么?如果我创建 FirefoxDriver 并将 UseLegacyImplementation 选项设置为 true(因此绕过 geckodriver),那么一切正常。
【问题讨论】:
-
超时是因为浏览器无法回复驱动。这可能是因为您使用的驱动程序版本与 ESR 52 不兼容。建议的最低版本为 55。
-
oo...好信息@FlorentB。你能指出你推荐的版本信息的来源吗?
-
查看关于 v0.19.0 版本的评论:github.com/mozilla/geckodriver/releases
标签: c# selenium selenium-webdriver selenium-firefoxdriver geckodriver