Joshua Burns Joshua Burns - 1 month ago 19
C# Question

Updating to Marionette Driver C#

Ok so as many of you fellow webdriver testers know the release of Firefox 47 has broken the Webdriver.FirefoxDriver. All the documentation I can find tells me that the new FirefoxDriver is Marionette.

So I have downloaded the latest executable from https://github.com/mozilla/geckodriver/releases
renamed to wires.exe and moved into my test directory.

Here is my setup method

[TestFixture("chrome")]
[TestFixture("firefox")]
//[TestFixture("internet explorer")]
[Category("ExistingUser")]
public class ExistingUserTestSuite
{
public string browser;
public IWebDriver Driver { get; set; }
public UserInfo User { get; set; }
private static readonly log4net.ILog log = log4net.LogManager.GetLogger("ExistingUserTest");

public ExistingUserTestSuite(string browser)
{
this.browser = browser;
}



[OneTimeSetUp]
public void SetUp()
{
switch (browser)
{
case "chrome":
Driver = new ChromeDriver();
break;
case "firefox":
FirefoxOptions op1 = new FirefoxOptions();
op1.IsMarionette = true;
op1.AddAdditionalCapability("marionette", true);
Driver = new FirefoxDriver(op1);
break;


When I try to run I get the following exception. I can see that the wire.exe process is running in process explorer when I start the tests.

Test Name: ChangePlan
Test FullName: POMAuctivaTest.TestSuite.ExistingUserTestSuite("firefox").ChangePlan
Test Source: c:\git\POMAuctivaTest\POMAuctivaTest.TestSuite\ExistingUserTestSuite.cs : line 359
Test Outcome: Failed
Test Duration: 0:00:00.0000001

Result Message: OneTimeSetUp: System.InvalidOperationException : entity not found


Here is the stack trace generating the exception

at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxDriverService service, FirefoxOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxOptions options)
at POMAuctivaTest.TestSuite.ExistingUserTestSuite.SetUp() in c:\git\POMAuctivaTest\POMAuctivaTest.TestSuite\ExistingUserTestSuite.cs:line 56


Most advice I see is regarding making sure your system path is updated. I feel this is not the case here as if I remove the wire.exe from my test/bin/debug folder I get the following exception.

Test Name: ChangePlan
Test FullName: POMAuctivaTest.TestSuite.ExistingUserTestSuite("firefox").ChangePlan
Test Source: c:\git\POMAuctivaTest\POMAuctivaTest.TestSuite\ExistingUserTestSuite.cs : line 359
Test Outcome: Failed
Test Duration: 0:00:00.0000001

Result Message: OneTimeSetUp: OpenQA.Selenium.DriverServiceNotFoundException : 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 https://github.com/jgraham/wires/releases.


This tells me that I am finding the driver but for some reason cannot create an instance of
FirefoxDriver()
.

Not sure what to do here, any help would be nice.

Answer

Well after what felt like a wild goose hunt I found this little gem in an open issue on the geckodriver github page. I have confirmed that this has fixed my issue and now I am able to create an instance of firefox driver and successfully open Firefox 47. https://github.com/mozilla/geckodriver/issues/91

Here is a snippet of the code from the above URL in case the link goes dead

FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
service.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
IWebDriver driver = new FirefoxDriver(service);

Hope this helps others. But there is a bug which is currently a blocking issue for all my tests. All of my tests access our internal test environments which have self signed certs and there is a bug with marionette where you cannot handle these. https://bugzilla.mozilla.org/show_bug.cgi?id=1103196

=(

Comments