How to Correctly Use GeckoDriver To Run Webdriver Automation Test Script

You can not initialize Firefox browser object directly in selenium 3 like before. You need to download an executable file which is called GeckoDriver and set it’s path to a system variable like using IE or Chrome in webdriver. Now i will show you how to use GeckoDriver to write selenium automation test script in java.

Introduction to Gecko  and  GeckoDriver

Gecko is an extremely fastest internet web browser engine. It is used widely in Mozilla Foundation developed applications include Firefox.

GeckoDriver is the bridge between Firefox web browser and selenium automation test scripts. Because selenium 3 will not support Firefox in native implementation, so we have no choice but direct all selenium webdriver commands in automation test script to Firefox web browser through GeckoDriver like IE and Chrome.

Download the GeckoDriver before using it 

To use Gecko Driver to open Firefox web browser in your selenium automation test script you need to download the executable file first. Click here to download it.
GeckDriver download page

Download the zip file which meet your operating system. I just download  as i use a 64 bit windows operating system.

After download unzip it to a local directory. I unzip it into C:\Workspace\\Lib\geckodriver-v0.16.1-win64.

how to use it in your selenium automation test project

It is very easy to use Gecko Driver in your java project. It is similar as using IE and Chrome Driver. All you have to do is just set the Gecko Driver executable file path as the value of your system variable “webdriver.gecko.driver”. Below is the java code.

 //assign webdriver executable file path to the value of system variable
 System.setProperty("webdriver.gecko.driver", "C:\\Workspace\\\\Lib\\geckodriver-v0.16.1-win64\\geckodriver.exe");
 //Initiate a browser
 WebDriver fireFoxGeckoDriver = new FirefoxDriver();
 //Browse website
 //Quit web browser

[download id=”344″]

0 0 vote
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x