Launch Firefox Browser using Selenium:

 

  • WebDriver‘ is an interface and we are building a reference variable ‘driver‘ using the ‘FirefoxDriver()‘ class, a quick webdriver.
  • WebDrivers for different browsers: FirefoxDriver() for Firefox browser, ChromeDriver() for Google Chrome, SafariDriver() for Safari Browser, InternetExplorerDriver for Internet Explorer etc.
  • Webdriver is an Interface and FirefoxDriver() is a class which has implemented Webdriver Interface.
  • Interface, there is a set of variables and methods without any body (no implementation, only method name and signature). We can not instantiate objects from the interface.
  • WebDriver is an interface which contains all the unimplemented common methods, which can be used for any browser e.g. getTitle(), getCurrentUrl(), get(), findElement() etc.

 

Download Geckodriver.exe:

 

  • Set the system property for “webdriver.gecko.driver” with Geckodriver.exe path – System.setProperty (“webdriver.gecko.driver”, “geckodriver.exe path”);

 

What is GeckoDriver?

 

  • A proxy for W3C WebDriver-compatible clients to interact with Gecko-based browsers.
  • Geckodriver provides the HTTP API described by the WebDriver protocol, so that Gecko browsers, such as Firefox.
  • Mozilla runs on Gecko browser engine.
  • As part of the Mozilla Browser, the Gecko Browser Engine was developed by the Mozilla Foundation.
  • It can help applications render web pages, just like other browsers, Chrome, Internet Explorer and Edge Mozilla Foundation have decided to introduce the Marionette driver to control Firefox browser.
  • This is an open source browser engine, which can be used by any person. However, the Gecko browser engine is not limited to the Mozilla browser.

 

Specify System Properties with Path:

 

Example of Launch Firefox Browser using geckodriver:

Output: 

 

Importing packages:

  • org.openqa.selenium. * : Includes the required WebDriver class to instantiate a new browser loaded with a specific driver.
  • org.openqa.selenium.firefox.FirefoxDriver : The FirefoxDriver() class is required to install Firefox-specific drivers via the WebDriver class immediately to the browser.