Selenium Firefox Marionette 带有 .NET C# 的驱动程序

Selenium Firefox Marionette Driver with .NET C#

我最近一直在使用 Selenium (http://www.seleniumhq.org/) 进行测试。它随机停止工作,我认为这是由于 Selenium WebDriver 2.53.0 不再与 Firefox 47 兼容(处理 Firefox 浏览器的 WebDriver 组件 (FirefoxDriver) 已停产)。

Marionette ([https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver#.NET][2]) 是下一代的 FirefoxDriver,我一直试图让它在我的机器上运行,但没有成功。

我目前已经下载了驱动程序,并将文件重命名为wires.exe并保存在我网站的根目录中。然后我添加了以下代码:

string strWires = @"Z:\Web_Development\Websites\test\wires.exe";
Environment.SetEnvironmentVariable("webdriver.gecko.driver", strWires);

FirefoxOptions options = new FirefoxOptions();
options.IsMarionette = true;
FirefoxDriver driver = new FirefoxDriver(options);

但是我收到以下错误消息:

"An exception of type 'OpenQA.Selenium.DriverServiceNotFoundException' occurred in WebDriver.dll but was not handled in user code

Additional information: The wires.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at github.com/jgraham/wires/releases."

如果有人知道如何让 Marionette 驱动程序与 Selenium 一起工作(或者甚至可以为我指明正确的方向)并提供分步说明,我们将不胜感激?

谢谢,

丹尼尔

Marionette 似乎想使用 FireFox 的夜间构建。下载Geckodriver,重命名为wires.exe,复制到输出。 这对我有用(FireFox 47 和 Selenium 2.53.0):

var driverService = FirefoxDriverService.CreateDefaultService();
driverService.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
driverService.HideCommandPromptWindow = true;
driverService.SuppressInitialDiagnosticInformation = true;

var driver = new FirefoxDriver(driverService, new FirefoxOptions(), TimeSpan.FromSeconds(60));