Site icon TestingDocs.com

Selenium 3.0 and Mozilla GeckoDriver

Introduction

In this article, we will discuss what’s new in Selenium 3.0 and the 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:

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 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 )

 

Selenium Tutorials

Selenium WebDriver Tutorials on this website can be found at:

https://www.testingdocs.com/selenium-webdriver-tutorial

For more details on the Selenium, visit the official website at:

https://www.selenium.dev/

 

Exit mobile version