Using Portable Firefox 46 with WebDriver

As mentioned on David Burns’ blog and in a previous post here Firefox are moving towards Marionette driver. At the time of writing Firefox 47 doesn’t work with FirefoxDriver and you need to use Marionette. This may change back soon, and David’s blog post might no longer be available.

As mentioned on the above posts you can use Marionette, or use the ESR.

OR you could use a portable version of Firefox.

Rather than try and toggle multiple versions of Firefox. I downloaded a portable version of Firefox. I used a version distributed by portableapps.com. Having a portable app means I can run 46 and 47 at the same time and don’t have to uninstall 47 to use 46. The portable app puts all its DLLs in the app folder and doesn’t really ‘install’ it mostly un-archives itself.

On the sourceforge site for portableapps they have a set of older Firefox versions:

I downloaded a version of Firefox 46.0.1

I extracted/installed this to my ‘tools’ folder which is a peer of my ‘code’ folder:

  • code
    • pom.xml
    • src
  • tools
    • chromedriver
    • marionette
    • iedriver_64
    • etc.

And now I have a FirefoxPortable folder in my tools folder.

When I instantiate a FirefoxDriver I no longer write:

WebDriver firefox = new FirefoxDriver();

Because that would trigger the “Firefox is no longer working” error.

Instead, I tell the FirefoxDriver which executable to use:

FirefoxProfile profile = new FirefoxProfile();
firefox = new FirefoxDriver(
                 new FirefoxBinary(
                     new File(System.getProperty("user.dir"),
                     "/tools/FirefoxPortable/FirefoxPortable.exe")
                  ), 
               profile);

And then I can run my @Test code as normal without having to use Marionette.

Obviously you can abstract this instantiation into a class so you don’t have to change code everywhere.

I have updated my ‘start using selenium webdriver’ github repo to have examples of the different approaches for instantiating Firefox.

 

This entry was posted in Firefox, WebDriver. Bookmark the permalink.

Leave a Reply

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