paint-brush
How to Run Selenium Tests on Firefox using Firefox Driver by@jash_unadkat
3,299 reads
3,299 reads

How to Run Selenium Tests on Firefox using Firefox Driver

by Jash UnadkatJune 7th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Selenium uses Firefox Driver to link the test cases with the Firefox browser. GeckoDriver is a browser engine developed by Mozilla for many applications. Without the help of Gecko driver, one cannot instantiate the object of Firefox browser and perform automated Selenium testing. We will perform 3 simple steps: Launch Firefox browser, navigate through Google.com and give the search result as shown below. Selenium Java Guide: How to run Selenium Tests on IE using Selenium IE Driver. How to Run Selenium tests on Firefox using Firefox Driver:770770 reads.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - How to Run Selenium Tests on Firefox using Firefox Driver
Jash Unadkat HackerNoon profile picture
  uses to link the test cases with the Firefox browser. In this guide, we discuss how Selenium Firefox driver aka GeckoDriver works with the help of an example.Before proceeding further, learn how to execute Selenium test cases with Let’s get started.

What is a Selenium Firefox Driver?

Selenium Firefox Driver, also called GeckoDriver is a  developed by Mozilla for many applications. It provides a link between test cases and the Firefox browser. Without the help of GeckoDriver, one cannot instantiate the object of Firefox browser and perform . One can easily initialize the object of GeckoDriver using the following command:Basic Setup:

Step 1: Navigate to the . Under third-party drivers, one will find all the drivers. Just click on the Mozilla GeckoDriver documentation

Step 2: After that, check the latest supported platforms of GeckoDriver versions in the documentation and click on GeckoDriver releases .

Now, it will navigate to the , where one can download the suitable driver based on the OS as it is platform agnostic. The snapshot below depicts all the available Selenium Firefox Driver releases.

Step 3: Once the zip file is downloaded, open it to retrieve the geckodriver executable file.

Step 4: Copy the path of the GeckoDriver and set the properties to launch the browser and perform testing.

Also learn :  How to run Selenium Tests on IE using .

Sample test case: We will perform 3 simple steps:

1. Launch Firefox browser
2. Go to Google website
3. Enter search query as - BrowserStack Guide.

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Firefox_Example{
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver",Path_of_Firefox_Driver"); // Setting system properties of FirefoxDriver
WebDriver driver = new FirefoxDriver(); //Creating an object of FirefoxDriver
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("//www.google.com/");
driver.findElement(By.name("q")).sendKeys("Browserstack Guide"); //name locator for text box
WebElement searchbutton = driver.findElement(By.name("btnK"));//name locator for google search
searchbutton.click();
driver.quit();
}
}

On executing the code, GeckoDriver will launch Firefox browser, navigate through google.com and give the search result of the Browserstack Guide page as shown below.

For user willing to automate test cases on Chrome, they can refer to this article Automation using

바카라사이트 바카라사이트 온라인바카라