Firefox Browser via GeckoDriver in Selenium 3 (Beta 1)

Selenium 3(Beta 1) got released and Important changes are listed here.

IMPORTANT CHANGES
 * Minimum java version is now 8+
 * The original RC APIs are only available via the leg-rc package.
 * To run exported IDE tests, ensure that the leg-rc package is on the classpath.
 * Support for Firefox is via Mozilla’s geckodriver. You may download this from Gecko Driver Release
 * Support for Safari is provided on macOS (Sierra or later) via Apple’s own safaridriver.
 * Support for Edge is provided by MS:
 MicrosoftWebDriver Download
 *Official support for IE requires version 9 or above. Earlier versions may work, but are no longer supported as MS has end-of-lifed them.
 Other major changes:
 * New html-table runner backed by WebDriver.
 * Unused command line arguments are now no longer parsed

Download Selenium 3 (Beta 1) jars from Selenium Java Jars Download Page

Firefox via GeckoDriver Example:

In Selenium 2.0 (Webdriver), we used FirefoxDriver as the default driver as
 WebDriver driver = new FirefoxDriver();

But in Selenium 3 (Beta 1) it throws an exception saying “lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver”

In order to work with FirefoxDriver in Selenium 3 Beta version,

  • Download GeckoDriver from Gecko Driver Release
  • Extract the zip file and give the path of the geckodriver exe in the program.
  • You need to use webdriver.gecko.driver for setting the System Property

Sample Program:

Tested with Firefox 47.0.1 version and is working fine.

Originally published at testingmindsblog.wordpress.com on August 1, 2016.