Launch of Firefox Browser through Selenium 3:

In last post, we have learnt how to launch Chrome driver through selenium. In this post we will learn:

  1. How to launch Firefox browser through Selenium 3.
  2. Open a URL in browser.
  3. Close the browser.

Selenium 3 has been launched. In selenium 2, it was very easy to launch Firefox browser as Selenium 2 had native implementation of Firefox browser. As we know that Selenium provides a driver class for each browser. So to open Firefox browser, we just need to create an object of FirefoxDriver class as below:

FirefoxDriver driver= new FirefoxDriver();

Note: “driver” is an object or reference variable of class FirefoxDriver. You can name it anything you wish. Someone asked me that is “driver” fixed. So, I am putting this point here.

Selenium 3 has not any native implementation of Firefox browser. Marionette is the next generation of FirefoxDriver. Marionette is an automation driver for Mozilla’s Gecko engine. Gecko is the proprietary web browser engine design and developed by Mozilla. It can remotely control either the UI or the internal JavaScript of a Gecko platform, such as Firefox. So, to support Selenium webdriver, Gecko has released Geckodriver which is a proxy for using W3C WebDriver-compatible clients to interact with Gecko-based browsers.

How to launch Firefox browser in SELENIUM 3:

Step 1: Download the latest geckodriver from here as per your system configuration. I will download for windows 64 bits.

Step 2: Extract it and so that you will get geckodriver.exe.

Step 3: Just set the system property using System class and setProperty method of it as we did for chrome browser in previous post.

Java code for opening Firefox browser is as below:

Note:

There are some issues with geckodriver. Sometimes we will face:

  1. Browser remains minimized after opening.
  2. quit() will give exception.
  3. Syncing issue between versions of geckodriver and Firefox.

That’s it for this post. I hope, you must have get above concepts. Feel free to ask any doubt if you have or any suggestion for me.

#HappyLearning

Author: Amod Mahajan