Selenium Firefox Marionette Driver with .NET C#

Daniel Wainwright picture Daniel Wainwright · Jun 13, 2016 · Viewed 11k times · Source

I've been using Selenium (http://www.seleniumhq.org/) recently for testing purposes. It randomly stopped working and I believe this is due to Selenium WebDriver 2.53.0 not being compatible with Firefox 47 anymore (the WebDriver component which handles Firefox browsers (FirefoxDriver) has been discontinued).

Marionette ([https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver#.NET][2]) is the next generation of FirefoxDriver and I've been trying to get this to work on my machine but have had no luck.

I have so far downloaded the driver, renamed the file as wires.exe and saved in the root directory of my website. I have then added the following code:

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);

I recieve the following error message however:

"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."

It would be very much appreciated if anyone knows how to get the Marionette driver working with Selenium (or could even just point me in the right direction) and could provide step by step instructions?

Thanks,

Daniel

Answer

Gabi Nitulescu picture Gabi Nitulescu · Jun 15, 2016

Marionette seems to want to use the nightly build of FireFox. Download Geckodriver, rename it to wires.exe, copy to output. This works for me (FireFox 47 and 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));