Software Testing

Selenium 3.0 and Mozilla GeckoDriver

Selenium 3.0 and Mozilla GeckoDriver

In this article, we will discuss what’s new in Selenium 3.0 and the GeckoDriver sample code. To download and learn 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

GeckoDriver is a proxy for using W3C WebDriver-compatible clients to interact with Gecko-based browsers. GeckoDriver provides HTTP API described by the WebDriver protocol to communicate with Gecko browsers, such as Firefox (Version after 47).  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.

Marionette (the next generation of FirefoxDriver) is turned on by default from Selenium 3. Even if you are working with older versions of Firefox browser, Selenium 3 expects you to set path to the driver executable by the webdriver.gecko.driver.

Click here For more details on Marionette:

  • https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette

 

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

You can find the latest executable of GeckoDriver on 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.

Sample Test

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