Run Test on Firefox Browser

Gecko browser engine was developed by Mozilla foundation as a part of Firefox browser. It is an open-source browser engine that can be used by anyone in their application to render web pages.

Firefox browser implements the WebDriver protocol using Gecko driver. It acts as a proxy between W3C WebDriver-compatible clients (Eclipse, Netbeans, etc.) to interact with Gecko-based browser (Mozilla Firefox).

Marionette (the next generation of FirefoxDriver) is by default turned on from Selenium 3. Selenium uses W3C Webdriver protocol for sending requests to GeckoDriver, which further translates into a protocol named Marionette.

Let’s start with Testcase by opening firefox browser and navigate tohttps://demoapp1.tequality.tech/and close the browser

 

Step1: Right click on src folder and select New > Class

 

Step2: Provide Class Name and click on Finish

 

Step3: Open URL:   https://github.com/mozilla/geckodriver/releases in your browser and select any of the latest driver version according to your browser version. Download and unzip file.


Step4:
Set a system property “webdriver.gecko.driver” to the path of your GeckoDriverServer.exe file and instantiate an GeckoDriver class.

Here below your test script will look like

 

import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class DemoFirefoxTest {

public static void main(String[] args) {

// System Property for Gecko Driver
System.setProperty("webdriver.gecko.driver","D:\GeckoDriver\geckodriver.exe" );

// Initialize Gecko Driver
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette",true);
WebDriver driver= new FirefoxDriver(capabilities);

// Launch Website and navigate to URL
driver.get("https://demoapp1.tequality.tech/");

//close the browser
driver.close();

}

}


Step5:
Run the code by right click on the Eclipse code and select Run As > Java Application