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 geckodriver-v0.16.1-win64.zip  as i use a 64 bit windows operating system.

After download unzip it to a local directory. I unzip it into C:\Workspace\dev2qa.com\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\\dev2qa.com\\Lib\\geckodriver-v0.16.1-win64\\geckodriver.exe");
 //Initiate a browser
 WebDriver fireFoxGeckoDriver = new FirefoxDriver();
 //Browse website http://www.dev2qa.com
 fireFoxGeckoDriver.get("http://www.dev2qa.com");
 //Quit web browser
 fireFoxGeckoDriver.quit();

Download “TestWithFirefoxGeckoDriver.zip” TestWithFirefoxGeckoDriver.zip – Downloaded 29 times – 588 B

(Visited 289 times, 1 visits today)
READ :   How To Setup Selenium Grid In Selenium Testing Automation

Leave a Reply

Your email address will not be published. Required fields are marked *