簡體   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