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:
- code
-
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.
Published at DZone with permission of Alan Richardson, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments