繁体   English   中英

使用.NET C#的Selenium Firefox木偶驱动程序

[英]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);

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

“WebDriver.dll中出现'OpenQA.Selenium.DriverServiceNotFoundException'类型的例外,但未在用户代码中处理

附加信息:wires.exe文件不存在于当前目录或PATH环境变量的目录中。 该驱动程序可以从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));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM