• info@helpingtesters.com
  • helpingtesters

Whats new in Selenium 3.0

November 13, 2017 Selenium Tutorial
Selenium 3.0

Before starting with What’s new in Selenium 3.0, we shall first glance through Selenium 2.0.

Walk Through of Selenium 2.0

Minimum Java version required is below 1.8

  • Support Firefox browser version below 47.0
  • It supports IE Versions 7, 8, 9, 10 and 11. Version 11 requires additional configuration.
  • It supports HeadLess Browser with HtmlWebDriver
  • Last 2.x version was v2.53.0. This was a stable build means it has no major issues.
  • Selenium 2 supported selenium core for backward compatibility. 

New Changes in Selenium 3.0

 Minimum Java version required is 1.8+

  • Firefox is fully supported at version 47.0.1 or earlier. Gecko driver provides support
    for later versions of Firefox. Firefox 47.0.1 and before would not need GeckoDriver
  • Selenium project will not actively support the WebDriver API.
  • The Selenium RC APIs are only available via the legacy-rc package.
  • Support Firefox browser via Mozilla’s gecko driver.
  • Selenium 3.0 does not have HeadLess Driver (HtmlWebDriver)
  • Official support for IE browser requires 9 or above version.
  • No need to maximize the browser using driver.manage().window().maximize(); By default it will maximize the window.
  • Apple has come up with its own SafariDriver to run your tests in Safari on Mac
  • Selenium RC core library won’t be supported.
  • Selenium WebDriver has become the W3C Standard. The W3C standard will encourage compatibility across different software implementations of WebDriver API.
  • All WebDrivers are moved out of selenium and vendors will be responsible for owning the drivers for maintenance, which will be the relief for maintenance team or open source team to get better implementation.

Issues found in Selenium 3.0

  • Unsupported Marionette protocol version 2, required 3 when our Firefox is 64 bit.
  • driver.close() is not working

Minimum Java version required is now 8+

Using WebDriver we can make dynamic scripts on web pages which change every day and we can make our scripts to run on multiple browsers. To start with WebDriver first we need to download the WebDriver Jars and Configure them in eclipse. Here the thing is that WebDriver is not installed it is configured. We have to download the Jar files of WebDriver from the official website of selenium which is seleniumhq.org. Go to download session and under the download session, we can see the latest version which is 3.0 beta4. If we go to the change log session last 2.x version was v2.53 which was stable build means which has no major issues. After v2.53 the next build which came up was v3.0-beta1. Now in v3.0 they did some changes, not major changes that are Minimum Java version now required is Java 8+, and make sure that we have JDK 8 installed.

Go to Google and type download JDK and go to the first link and go to download session and can download Java 8 for our machine, based on our machine we need to install 64 bit or 32 bit and accept the agreement and download the exe file.

If we are working with v2.53.0 then we need Firefox 40 or below and if we are using v3.0 then we have to go for the latest version of Firefox 3.x and if latest is not working then go for latest 1 / 2 fewer versions.

GeckoDriver

Gecko is a web browser used in many applications developed by Mozilla Foundation. Gecko Driver is the link between your tests in selenium and Firefox browser. we have to direct all the driver commands through Gecko Driver because Selenium 3.0 will not have any native implementation of Firefox. FirefoxDriver is an inbuilt class. Selenium 3.0 doesn’t support Firefox 47.0.0 version at all. Firefox is fully supported at version 47.0.1 or more. If we want to write your tests on Firefox browser using selenium 3.0, you’ll need to have the gecko driver which supports for later versions of Firefox, which is an executable file similar to the chrome driver and edge driver. GeckoDriver.exe represents Firefox browser implements the WebDriver protocol which is used to start a server on your system which communicates all our tests to this server to run our tests.

Downloading Gecko Driver

  

  • Right click on the downloaded folder and select Extract All to UnArchive the folder.

 

  • Chose the path or folder of your choice.

Below is the syntax to run selenium on FirefoxDriver

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

WebDriver driver = new FirefoxDriver();

Example:

Create a New Class: Driver_Selenium

import org.openqa.selenium.friefox.FirefoxDriver;

public class Driver_Selenium {

public static void main(String[] args) {

// Create an object of FirefoxDriver class.

new FirefoxDriver();

}

}

When we run the above program we get an exception. In order to overcome this exception, we need to download an exe file. Go to download session under seleniumhq.org and go to Mozilla GeckoDriver and click on the link which navigates to next page where we can download it based on our operating system (gecko driver-v0.10.0-win64.zip). Now extract the downloaded file and set the system property known as webdriver.gecko.driver  and give the path of the exe file as below.

import org.openqa.selenium.friefox.FirefoxDriver;

public class Driver_Selenium {

public static void main(String[] args) {

System.setProperty(“webdriver.gecko.driver” , “F:\\drivers\\geckodriver.exe”);

// Create an object of FirefoxDriver class.

FirefoxDriver fd = new FirefoxDriver();

}

}

Now when we run the above program a blank Firefox opens up.

Set the property in Environment Variables

If you don’t want to set the System property every time in the test script, we need to set the path as below where our test script will work without System Property code.

  • Go to My Computer and Right click and Click on Properties
  • Click on Change Settings

  • Click on the Advance tab in the System Properties window and click on Environment Variables button.

  • Under the System variables, select Path and click on Edit button.

  • At the end of the string enter semicolon and paste the path of the GeckoDriver.

Example to Run tests on Remote machine with Firefox gecko driver

To execute tests on the remote machine with Firefox gecko driver, WebDriver has to use RemoteWebDriver and DesiredCapabilities.

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.openqa.selenium.remote.DesiredCapabilities;

public class Remote_Gecko_Driver {

public static void main(String[] args) throws InterruptedException {

DesiredCapabilities capabilities = DesiredCapabilities.firefox();

capabilities.setCapability(“marionette”, true);

WebDriver driver = new FirefoxDriver(capabilities);

driver.get(“http://www.gmail.com”);

Thread.sleep(3000);

driver.quit();

}

}

Upgrade Existing selenium version in dependency to your pom.xml

<dependency>

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

<artifactId>selenium-java</artifactId>

<version>3.0.1</version>

</dependency>

Launching Edge Browser Using Microsoft WebDriver

Before proceeding, we need some Pre-requisites to start using Edge with Selenium WebDriver like Windows 10 and Microsoft WebDriver server version for our build. In order to launch Edge browser, we need to specify the system property with the path of MicrosoftWebDriver.exe file.

Syntax:

String driverPath = “<path to Microsoft edge driver>”

System.setProperty(“webdriver.edge.driver”, driverPath+”MicrosoftWebDriver.exe”);

driver = new EdgeDriver();

Example:

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.edge.EdgeDriver;

public class LaunchEdgeBrowser {

public static void main(String[] args) {

// Set the driver path

System.setProperty(“webdriver.edge.driver”,”C:\\Program Files (x86)\\Microsoft Web Driver \\MicrosoftWebDriver.exe”);

WebDriver driver = new EdgeDriver();

driver.get(“http://gmail.com”);

}

}

About the author

vinodreddy author

Leave a Reply

Your email address will not be published.