【发布时间】:2016-09-07 15:57:04
【问题描述】:
我们在 .Net 自动化测试项目设置中运行 Selenium 2.5.3 作为 NUnit 测试项目。
在 Firefox 47 上一切正常。但在 Firefox 48 上它停止了工作。 我从 github 下载了 Gecko.exe(版本 9)。 我几乎可以让它运行,但不完全。
我收到以下错误: 附加信息:对 URL http://localhost:53628/session 的远程 WebDriver 服务器的 HTTP 请求在 30 秒后超时。
附加信息:对 URL http://localhost:55924/session 的远程 WebDriver 服务器的 HTTP 请求在 30 秒后超时。
似乎默认是使用随机端口。 所以我手动将其设置为端口 7500,在 Windows 防火墙中打开该端口,现在我得到了这个: 附加信息:无法在http://localhost:7500/ 上启动驱动程序服务
这是我在 WebDriverFactory 中的代码:
case WebDriverType.Firefox:
Log.Info("Starting Firefox ...");
//string driverPath =
// $"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase)}\\wires.exe";
string driverPath =
@"C:\Development2\iRePORT\src\test\csharp\Nete.Ireport.EndToEndTests\bin\Debug\geckodriver.exe";
FirefoxDriverService driverService = FirefoxDriverService.CreateDefaultService();
driverService.FirefoxBinaryPath = driverPath;
driverService.Port = 7500;
FirefoxOptions ffOptions = new FirefoxOptions();
ffOptions.IsMarionette = true;
driver = new FirefoxDriver(driverService, ffOptions, TimeSpan.FromSeconds(30));
// driver = new FirefoxDriver(new FirefoxOptions());
Log.Info("Started");
break;
我在这方面花了很多时间,我觉得我很接近。 有谁知道我错过了什么?
我现在读到一些让我想到这一行的东西;
driverService.FirefoxBinaryPath = driverPath;
指向要使用的 Firefox 安装版本。 我现在将驱动程序路径和可执行文件名称放在 driverService 构造函数中,如下所示:
case WebDriverType.Firefox:
Log.Info("Starting Firefox ...");
//string driverPath =
// $"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase)}\\wires.exe";
string driverPath =
@"C:\Development2\iRePORT\src\test\csharp\Nete.Ireport.EndToEndTests\bin\Debug";
string driverExecutableName = "geckodriver.exe";
FirefoxDriverService driverService = FirefoxDriverService.CreateDefaultService(driverPath, driverExecutableName);
// Don't do this!!! This is the executable to the Firefox Version executable.
//driverService.FirefoxBinaryPath = driverPath;
driverService.Port = 7500;
FirefoxOptions ffOptions = new FirefoxOptions();
ffOptions.IsMarionette = true;
driver = new FirefoxDriver(driverService, ffOptions, TimeSpan.FromSeconds(30));
// driver = new FirefoxDriver(new FirefoxOptions());
Log.Info("Started");
break;
所以现在我又回到了这个错误: 附加信息:无法在http://localhost:7500/ 上启动驱动程序服务
如果我有: 驱动程序服务端口 = 7200; 它说“找不到实体”。我相信这意味着它找不到 Gecko.exe。 如果我有: 驱动程序服务端口 = 7500; 它说: 附加信息:无法在http://localhost:7500/ 上启动驱动程序服务
【问题讨论】:
-
在stackoverflow.com/questions/39005512/… 发布了可能与此问题相关的答案
标签: c# .net selenium firefox selenium-webdriver