.

Selenium 3 - Initialize FirefoxDriver using GeckoDriver


OS : Windows 64 bit

Selenium Version: 3.0.0-beta3
 
Browser: Firefox

Browser Version: 45.0
 

If you started working with Selenium 3, you should to be aware of the fact that

  •  it requires Java 8.
  •  it requires Mozilla's GeckoDriver  for Firefox
  •  and the path of Gecko Driver must passed through System property.

  1. Create a new project in  Eclipse.
  2. Download latest selenium Jar from http://www.seleniumhq.org/download/
    I used version 3.0.0-beta3 which is released on 2016-09-01.
  3. Add external library to the project by right clicking on project > Build Path > Configure Build Path
  4. Create a new package. And create a new class in that package.
  5. Then in main method set path of gecko driver. make sure you have the latest geckodriver or you may face some issues. I used geckodriver 64 bit for windows v0.10.0 And try creating instance of FirefoxDriver.



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
package driverInvocation;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class FirefoxTest {
 
 public static void main(String[] args) {
  
  System.setProperty("webdriver.gecko.driver", "C:\\Work\\WORK\\Selenium\\geckodriver.exe");
  WebDriver driver = new FirefoxDriver();
  
  driver.get("http://www.google.com");

 }

}


It should launch firefoxdriver and open google.com.

If you face any issue then feel free to share.

1 comment :

  1. Hi.. I do have 32 bit windows and i saw the latest version of geckodriver for 32 bit windows is 8. It is not working properly in my eclipse. I am getting the below error message.
    Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: E:\SeleniumWS\SeleniumPgms\‪E:\SeleniumWS\SeleniumPgms\geckodriver.exe
    at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
    at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:121)

    ReplyDelete

Recent Posts