Hellohttps://secure.gravatar.com/avatar/c0e2513e2c522e46efd0f8138502c85c?s=96&d=mm&r=x

blogs

Introduction To Selenium 3.0: An Upgradation Using GeckoDriver

Introduction To Selenium 3.0: An Upgradation Using GeckoDriver 28 Nov,2016

Selenium 2.0 was released in 2011 and introduced the new WebDriver APIs that encouraged everyone to start moving to them. Selenium 3.0 is a simple drop-in upgrade version if you’re currently using the WebDriver APIs. None of the WebDriver APIs have been changed, and the code is essentially the same as the last 2.x release. Even if you’re using Selenium Grid, the same applies: in most cases, you can just drop in the new JAR, and you’re done.

At the same time as the Selenium project is shipping Selenium 3.0, internals of Firefox are being changed by Mozilla to make it more stable and secure which also makes the community-provided Firefox Driver no longer work. If you use Firefox for your testing, you’ll need to use the geckodriver, which is an executable similar to the chromedriver and MS’s edgedriver. Even if you’re using Selenium 2, you’ll need to start using geckodriver— the change is in the browser, not Selenium.

Gecko Driver:

 

It is a proxy for using W3C WebDriver-compatible clients to interrelate with Gecko-based browsers. Geckodriver provides HTTP API defined by the WebDriver protocol to connect with Gecko browsers, such as Firefox (Version after 47).

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

geckodriver-selenium-exception

Note: If we are using Selenium version below 2.53, we don’t need gecko additional driver.

If we are not doing so, it will throw exception “java.lang.IllegalStateException: The webdriver.gecko.driver system property must set the path to the driver executable;”

The other significant changes in Selenium 3.x are listed below:

* The original RC APIs are only available via the leg-rc package.

* Ensure that the leg-rc package is on the classpath, to run exported IDE tests.

* Minimum java version is now 8+.

* Official support for IE requires version 9 or above.

* Unused command line arguments are now no longer described.

* New html-table runner supported by WebDriver.

Now let us see the example to launch firefox browser with Selenium 3 using gecko driver:

System.setProperty(“webdriver.gecko.driver”, “path of geckodriver.exe”);

WebDriver driver = new FirefoxDriver();

package com.testing;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.testng.annotations.Test;

public class SeleniumWithGeckodriver {

      public WebDriver driver;

       @Test

      public void browserOpenUsingGeckodriver() {

              System.setProperty(“webdriver.gecko.driver”, “path of geckodriver.exe”);

              driver = new FirefoxDriver();

       }

       @Test

      public void openUrl() {

              driver.navigate().to(“http://www.google.com”);

              driver.manage().window().maximize();

       }

       @Test

      public void closeDriver() {

                     driver.close();

       }

}

To run tests on remote machines, WebDriver has to use the case of the DesiredCapabilities and RemoteWebDriver in order to specify version, platform and browser name to implement tests.

Usually to run tests on our local machine, we will just specify as WebDriver driver = new FirefoxDriver(); to run on Firefox browser.

We need to use remote webdriver to perform tests on remote machine. The sample code given below is to perform your tests on remote machine with Firefox gecko driver.

System.setProperty(“webdriver.gecko.driver”, “path of geckodriver.exe”);

DesiredCapabilities capabilities=DesiredCapabilities.firefox();

capabilities.setCapability(“marionette”, true);

WebDriver driver = new FirefoxDriver(capabilities);

 

The above code is verified Firefox 47+ version and selenium-server-standalone-3.0.0-beta2 version.

Just update/add the following selenium dependency to your pom.xml: in your Maven project.

 

    <dependency>

        <groupId>org.seleniumhq.selenium</groupId>

        <artifactId>selenium-java</artifactId>

        <version>3.0.0-beta2</version>

    </dependency>

With the latest versions of Firefox, the most common issue people are facing is org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.

Users can use Marionette (geckodriver), who are facing the above problem. Please do comment your observation/issue with the versions (Geckodriver, Firefox and Selenium) that you have used.

UPDATE:
User should be able to download Gecko Driver version 0.11 as it will resolve the issues related to windows32 bit.

 

suraj singh Suraj Singh works as Automation Test Engineer at BugRaptors. He is responsible for Automation testing on Web and Mobile application. He has working knowledge in Selenium Web driver(Web application), Appium(Android and iOS), Microsoft SQL Server and HP QTP (Web and window application).

Leave a Reply

Your email address will not be published. Required fields are marked *

Name field is required !

Related Posts

Introduction to Automated Testing Life-Cycle Methodology
Introduction To Selenium 3.0: An Upgradation Using GeckoDriver

Automated Testing Life-cycle Methodology is the process of testing which is executed in planned and a systematic manner. In this process, different ac...

Read More
Introduction To API's & How To Automate API's Testing With S...
Introduction To Selenium 3.0: An Upgradation Using GeckoDriver

An application-programming interface(API) consists of a set of standards and programming instructions for accessing a Web tool or Web-based software ...

Read More
How To Run Parallel Execution In Selenium Grid Using TestNG?
Introduction To Selenium 3.0: An Upgradation Using GeckoDriver

Selenium Grid is a proxy server that enables the user to run tests in parallel on multiple machines. It manages different browser versions and config...

Read More
Challenges and Opportunities Faced While Migrating To Seleni...
Introduction To Selenium 3.0: An Upgradation Using GeckoDriver

Organizations are getting digitally powered and are liable for ensuring digital empowerment for its customers. The Gartner's CIO Agenda (2016) Surve...

Read More

Popular Blogs

Augmented Reality Application Testing: Is It Really Worth Investing?
Augmented Reality Application Testing: Is It Really Worth Investing? Read More
Selenide vs. Selenium: The War Of Technologies!!!
Selenide vs. Selenium: The War Of Technologies!!! Read More
Disability can’t be a Restriction: Make Web Accessible for Everyone.
Disability can’t be a Restriction: Make Web Accessible for Everyone. Read More
Cloud Load Testing Strategy to Enhance Your Business
Cloud Load Testing Strategy to Enhance Your Business Read More
Different Types of User Acceptance Test, Are You Performing All?
Different Types of User Acceptance Test, Are You Performing All? Read More

Sign up FOR NEWSLETTER !

Do you want to automate your web application?
contact us