Setting up Marionette/ GeckoDriver

 

Firefox will crash if you are using the Webdriver implementation for FirefoxDriver with Firefox v47 and beyond. This needs to be replaced with Mozilla’s GeckoDriver/ Marionette. At the time of writing it is still in a pre-release stage; meaning you may get unpredictable results against the current stable version of Firefox. You may want to use it with Firefox Nightly or Firefox Developer.

Below are some steps to get you going with Marionette/ Geckodriver C# .Net:

  • Download the latest release here
  • Extract the *.exe middleware and rename it to ‘wires.exe’
  • Place ‘wires.exe’ in to the given source code location
  • Include ‘wires.exe’ into your Solution and set properties to ‘Copy if Newer’

To set the Driver up in code, I have found the following works well in C# .Net:

            FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
            service.FirefoxBinaryPath = @"C:\Path\to\your\FF\exe.exe";
            FirefoxOptions options = new FirefoxOptions();
            options.AddAdditionalCapability(CapabilityType.AcceptSslCertificates, true);
            TimeSpan t = TimeSpan.FromSeconds(10);

            Driver = new FirefoxDriver(service, options, t);

Note that you need to put in the path to your Firefox *.exe or add it to your system Path variable.

If you are experiencing issues I would recommend having a look at the project bug list or the project GitHub issues page before raising any issues. There is also much more information over at the Mozilla page for Marionette.



  • I want to set up a driver just like you have here, but I want to specify a Firefox Profile too. I tried adding a profile like this, but it seems to be ignored during the test:

    var profile = new FirefoxProfile();
    profile.SetPreference(“browser.download.dir”, SeleniumCoreSettings.DefaultDownloadDirectory);
    profile.SetPreference(“browser.download.folderList”, 2);
    profile.SetPreference(“browser.helperApps.neverAsk.saveToDisk”,
    “vnd.openxmlformats-officedocument.spreadsheetml.sheet”);

    var service = FirefoxDriverService.CreateDefaultService();
    service.FirefoxBinaryPath = @”C:\Program Files (x86)\Mozilla Firefox\firefox.exe”;
    var options = new FirefoxOptions();
    options.AddAdditionalCapability(FirefoxDriver.ProfileCapabilityName, profile.ToBase64String());
    Browser = new FirefoxDriver(service, options, commandTimeout);

    Thoughts on how I can pass a profile to the Marionette driver?

    • Hi Anthony,

      I had a quick crack at this and encountered the same issue. I haven’t found a work around at present. My use of the new driver has been pretty minimal due to other open bugs in the project so have reverted to using Firefox Portable (v47 i think!) to allow me to automate with one but also use the newer version, for the time being.

      Do let us know if you find a solution.

    • I had a little time to look into this today – update your Firefox to 47.0.1 and make sure you have Selenium 2.53.1. I was able to pass a profile like so:

      FirefoxProfile firefoxProfile = new FirefoxProfile(@”Path to profile”);
      FirefoxBinary bin = new FirefoxBinary(@”C:\Program Files (x86)\Mozilla Firefox\firefox.exe”);
      TimeSpan t = TimeSpan.FromSeconds(10);
      Driver = new FirefoxDriver(bin, firefoxProfile, t);

      Edit: Worth noting the following from Jim Evans “Please note that there is no version of the Selenium legacy (non-Marionette) Firefox driver that will work with Firefox 47.0.0. Also, no Selenium legacy (non-Marionette) Firefox driver version other than 2.53.1 will work successfully with Firefox 47.0.1.”

  • I’m learning Selenium WebDriver and trying to run a simple test using Firefox 50 and Webdriver 3.0.1. I’m using Marionette driver 0.11.1.

    I’m using an example here.

    When running the code, I’m getting the following exception:
    “An unhandled exception of type ‘System.Net.Sockets.SocketException’ occurred in System.dll” with additional information ” An invalid argument was supplied” on the line:

    FirefoxDriverService service = FirefoxDriverService.CreateDefaultService()

    What am I doin wrong?

    • It’s a bit difficult to tell with the small amount of information you have given but you should be able to get it working with something like the following:

          FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
                  FirefoxOptions options = new FirefoxOptions();
                  options.BrowserExecutableLocation = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";

                  TimeSpan t = TimeSpan.FromSeconds(10);

                  Driver = new FirefoxDriver(service, options, t);
  • Hello. I have the same issue as Eugene and Justin fix does not work. My code looks like that:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using OpenQA.Selenium;
    using OpenQA.Selenium.Firefox;
    using NUnit.Framework;

    namespace TestApp
    {
    class NUnitTest
    {
    IWebDriver driver;

    public object CSTimeSpan { get; private set; }

    [SetUp]
    public void Initialize()
    {
    FirefoxProfile profile = new FirefoxProfile();
    profile.SetPreference(“network.proxy.type”, 4);
    profile.SetPreference(“security.enterprise_roots.enabled”, true);
    driver = new FirefoxDriver(profile);

    }

    [Test]
    public void OpenAppTest()
    {
    driver.Url = “http://www.gazeta.pl”;
    }

    [TearDown]
    public void EndTest()
    {
    driver.Close();
    }
    }
    }

    Tried almost everything. It started from the situation that firefox had a connection problem, so i set proper profile. The driver.close did not work. driver.quit and dispose threw an error. Then i read about geko and marionette. I tried to set it but it still does not work. Please help… if You need any info just let me know.

    Regards

    • Hi Crazy Tester,

      Thanks for the code – it worked for me and also so did my code. Perhaps it is a compatibility issue of some kind? I would check your Firefox/ Selenium versions. Other than that, I’m not sure what else to suggest to you as I cannot replicate it.

      Here’s what I used:
      Selenium 3.0.1
      NUnit 3.5.0
      Firefox 50.1.0

      Good luck & Merry Christmas!

      • Hello,

        Actually I’m using the same. Additionally:
        Selenium.Support 3.0.1
        NUnit3TestAdapter 3.6.0

        The clue is that it opens browser, goes to the page and NOT closing it 🙁

        So as you see it is probably not the compatibility. I have no idea what to do. Is Does it close the browser for you?

        • So you weren’t having the same problem as Eugene. I did get it to close yes with driver.Dispose();

          [TearDown]
          public void EndTest()
          {
          driver.Close();
          driver.Dispose();
          }

          • Thanks for trying. I closed the browser but… It threw up and exception and a problem so this is not a solution 🙁 Maybe i should set the marionette driver? But i tried and it didn’t work. I have no idea what to do. But thanks for any help 🙂

            Merry Christmas!

  • This was a PITA, I had a old project with WebDriver 2.48, it worked fine with FF 28

    I updated to WebDriver 3 and the nightmare started, the browser starts but it does not shows the url.. after searched and searched in f*cking Google I ended here pffff so I just downgraded to 2.48 and everything is f*cking fine


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.