gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 18:34:45 29 4
gpt4 key购买 nike

我最近一直在使用 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));

关于c# - 带有 .NET C# 的 Selenium Firefox Marionette 驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37790417/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com