Selenium 3.0 and Mozilla GeckoDriver

Introduction

In this article, we will discuss what’s new in Selenium 3.0 and Geckodriver sample code. To download and to know more about selenium 3.0 Please find the official download page: http://www.seleniumhq.org/download/

Selenium 3.0 Changes

Some of the changes in Selenium 3.0 are mentioned below:

  • The Selenium RC APIs have been moved to a “legacy” package.
  • Until Selenium 3, Mozilla Firefox had built-in driver capabilities, unlike other browsers. Now, this accessibility has been removed. Also, Mozilla has made changes to the Firefox browser. Furthermore, Firefox 48 onwards you must use their geckodriver to use that browser, regardless of whether you’re using Selenium 2 or 3.
  • Webdriver and Selenium Grid bug fixes.

Upgrading to 3.0

If we use Maven upgrading to Selenium 3.x or later is simple. We can upgrade by using the maven dependency to 3.x or later by adding the following dependency to pom.xml .

     <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-server</artifactId>
          <version>3.3.1</version>
      </dependency>
      <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-firefox-driver</artifactId>
          <version>3.3.1</version>
      </dependency>
      <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-api</artifactId>
          <version>3.3.1</version>
      </dependency>
      <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-java</artifactId>
          <version>3.3.1</version>
      </dependency>
      <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-chrome-driver</artifactId>
          <version>3.3.1</version>
      </dependency>
      <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-ie-driver</artifactId>
          <version>3.3.1</version>
      </dependency>
      <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-edge-driver</artifactId>
          <version>3.3.1</version>
      </dependency>

 

If you are using RemoteWebDriver, you can add the following dependency to your pom.xml:

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.3.1</version>
</dependency>

 

Mozilla GeckoDriver

Mozilla has changed the internals of Firefox Browser. In simple terms, Firefox Driver will no longer work to run selenium tests from major version 48. As such, you’ll need to use the geckodriver, which is an executable something similar to Microsoft EdgeDriver.

To learn more about GeckoDriver, please read this post. Selenium3 : Marionette and GeckoDriver Example

You can find the latest executable of GeckoDriver on the GitHub. ( https://github.com/mozilla/geckodriver/releases )

The Selenium client bindings will try to locate the driver executable from the system path. You will need to add the directory containing the executable to the system path.

SampleTest

public class MozillaGeckoDriverExample { public WebDriver driver; @Test public void sampleGeckoTest() { System.setProperty("webdriver.gecko.driver", "geckodriver.exe"); driver = new FirefoxDriver(); driver.navigate().to("https://www.bing.com"); driver.manage().window().maximize(); Assert.assertEquals("Bing", driver.getTitle()); driver.quit(); }
}

 

Wrapping up

Geckodriver is not yet featured complete. This means that it is not yet fully compatible with Selenium. We can track the implementation status of the latest Firefox Nightly on MDN. We can also keep track of known problems and issue tracker.( https://github.com/mozilla/geckodriver/issues )