A few days ago, I was trying to run some tests on the Firefox 47.0 browser, using Selenium 2.53.0. Most of these tests failed apparently, with the Firefox browser just opening up and doing nothing that was mentioned in the script. After a bit of research, I found out that this was not something that I was not doing at my end- it was something that was changing the Selenium landscape as well.
Starting Firefox 48.0 and above, Selenium webdriver would not be supported by Firefox. This was confirmed by David Burns himself in the following comments, he made on a bug filed in Bugzilla, regarding Selenium tests getting failed in Mozilla.
The issue is that code to support cert override was changed in a way that broke Selenium which in turn then crashed Firefox. There is a fix in the works from Mozilla.
As a work around you can either revert to Firefox 46 or you can use Marionette*. We have documented how to get set up with Marionette on MDN.
- Note : When Extension Signing ships in Firefox 48 or later the current Selenium WebDriver addon approach will no longer work and you will need to update to Marionette.
There I read the concept of Marionette driver. Well, the name sounds fancy. What is it anyways?
As per this official posting by Mozilla-
Marionette is an automation driver for Mozilla’s Gecko engine. It can remotely control either the UI or the internal JavaScript of a Gecko platform, such as Firefox.
The document further says this –
If this sounds similar to Selenium/WebDriver then you’re correct! Marionette shares much of the same ethos and API as Selenium/WebDriver, with additional commands to interact with Gecko’s chrome interface. Its goal is to replicate what Selenium does for web content: to enable the tester to have the ability to send commands to remotely control a user agent.
So, basically, Mozilla is trying to implement something better for the Firefox’s Gecko engine. As per David’s comments and what I have read from the official documentation available here, it should allow us to do the same thing that Selenium webdriver allowed us to do, and also allow testers to interact with Gecko’s chrome interface. Sweet
Working
It is based on the usual client -server architecture. Marionette consists of two parts: A server which takes requests and executes them in Gecko, and a client. The client sends commands to the server and the server executes the command inside the browser. As simple as it is.
How To Use In My Python Tests
Looking at the marionette driver’s page, it currently supports Java, Python, Ruby, Node.js and .NET currently. For use in our day to day python tests, we need to follow the steps described in the simple tutorial here .
While you’re trying to use the marionette driver, there is a point mentioned in the tutorial that many of the Selenium client still don’t recognize the “Geckodriver” naming convention, which would cause issues in your tests. This happened with me, because I tried the “Geckodriver” naming and all of my tests – ran with Selenium 2.53.2 failed miserably. Renaming the executable downloaded to “wires” and changing the same in code did wonders and I was able to use Firefox the same way as I have been using in the past.
I tried this simple code for my Python script on marionette driver
from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities caps=DesiredCapabilities.FIREFOX caps["wires"]=True driver=webdriver.Firefox(capabilities=caps) driver.get("https://www.youtube.com/") print(driver.title) driver.quit()
If you don’t want to go through this process, you can have the marionette client installed for python, using pip, and then can use it in your unit tests. This page streamlines this process, and also has a very good documentation about the marionette driver, which I’m myself going on right now.
So, now we know that we’ll need to use marionette in future, it time that we start making the transition, since it’s gonna happen one day or the other.