How to run Selenium webdriver in Gecko Driver?

0
352
Executing Selenium WebDriver In Gecko Driver

Gecko Driver :

In Selenium WebDriver 2.0, the Firefox browser use to be the default browser of Selenium. Meaning to run the scripts using Firefox, you can directly execute the program.

After the upgradation of Selenium WebDriver 2.0 to Selenium WebDriver 3.0 version, the existing scripts of WebDriver 2.0 will not work for Firefox browser. Because Selenium 3 would not have the native implementation of Firefox.

What is Gecko?

Gecko is an inbuilt browser engine developed by Mozila.

What is GeckoDriver?

From Selenium WebDriver 3.0 the Firefox browser will not make direct calls to Selenium. Hence GeckoDriver will act as an intermediate for the communication between Selenium and Firefox browser. We need to have this Gecko Driver Executable stored in particular location. As we did it for other browsers like Chrome and Internet Explorer. The executable starts the server before executing the script using Firefox.

Downloading the Gecko Driver :

  1. Download the Gecko Driver from here. It is recommended to use the latest version of Gecko Driver.
  2. Based on your system requirement, download the 32 or 64 bit Gecko Driver zip file.
  3. Extract the Zip file and place the extracted content into an specified location.

 

First Script using Gecko Driver :

Explanation of the code :

Line 6 : This particular line is referring to the gecko Driver where the exe file is stored.

String GeckoPath = “D:\\Drivers\\geckodriver.exe”;

Line 7 : To set the system properties for Gecko Driver below line of code is used.

System.setProperty(“webdriver.gecko.driver”,GeckoPath);

LEAVE A REPLY

Please enter your comment!
Please enter your name here