Using Portable Firefox 46 With Webdriver
Need to use the portable version of Firefox 46 with webdriver? Alan Richardson gives you a code snippet to use to get it working without using Marionette!
Join the DZone community and get the full member experience.Join For Free
As mentioned on David Burns’ blog and in a previous post 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:
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.
Published at DZone with permission of Alan Richardson, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.