Saturday, September 16, 2017

Firefox Selenium Browser Capabilities explained

Contents:

1) Introduction
2) Getting started with Gecko Driver
3) Using Firefox Browser Capabilities

1) Introduction

Two very important Firefox news related to Selenium were published recently:
a) Selenium IDE will no longer be supported in Firefox 55+ (source)
b) Headless mode is now available (source)

First news isn't really that bad. Any time invested in IDE is basically wasted time, so I don't think there is too much to worry.

Second news is exciting though. I already announced it before in my Headless Chrome before, but now it's live and ready to play with.

To be honest this post was meant to be about Headless Firefox, but upon testing it and using my code from Browser Capabilities explained post I realized it's no longer valid. Using Firefox Profiles is now deprecated. From now on we should rely on Browser Capabilities and very familiar mechanism as the one already implemented for Chrome. The code changed very recently, because even official Java example in headless Firefox news is using deprecated methods. 

Before I delve deeper into headless mode (which I'll publish this month) let me show new way of handling Firefox browser in your test.

2) Getting started with Gecko Driver

As you probably already know at first you need to download geckodriver. On Mac it can be done be very quickly using brew.

Windows users have to also set gecko property (it's done automatically by brew on Mac).


3) Using Firefox Browser Capabilities

Using Firefox browser capabilities looks exactly as in Chrome. I'm sure my readers are already very familiar with how I handle capabilities. The code almost like copy/paste from my Chrome examples.


Thankfully we no longer have to rely on flaky Firefox Profile solution. What's even better, especially comparing to Chrome, is documentation. GeckoDriver GitHub page have it covered very well. I encourage you to take a look.

As usual I posted all the code from above in my GitHub Awesome Testing project.