SELENIUM BASICS:


SELENIUM WEBDRIVER:


TESTNG:


REPORTS:


BUILD & CONTINUOUS INTEGRATION TOOLS:


CROSS BROWSER TESTING:


MOBILE TESTING:


AUTOMATION FRAMEWORKS:


API Testing:


INTERVIEW QUESTIONS:


SAMPLE RESUME:

Selenium 4.0 – Introduction, New Features, Installation, What’s Deprecated

Selenium 4 Tutorial

In this post, we’ll take you through everything you need to know about Selenium 4. We’ll start with a basic introduction to Selenium, new features of Selenium 4, the Difference between Selenium 3.0 and Selenium 4.0, and the following.

Introduction Selenium:

Selenium is one of the leading test automation tools in the market. Selenium is first launched in 2004 as Selenium Core. In 2007, Selenium IDE & Selenium WebDriver are added. Later on, Selenium tools were named Selenium 2(2011), Selenium 3(2016). Now Selenium is coming as Selenium 4.0. 

Note: Still stable version is not released. The current version is Selenium 4 (Alpha 6), released on 28th April’19. We hope that all the features we are going to list here will be available in the next official Selenium 4 release. Until Selenium 4 is officially released, It’s not recommended to upgrade or migrate your existing Selenium Project

What’s New?

Selenium IDE:

To use this there is no need for extensive programming knowledge. It supports rapid test development. It is like a record and playback tool.

Selenium WebDriver:

It automates browser and supports programming languages like Java, JavaScript, Python, Perl, etc.,

Selenium Grid:

It allows us to run our test scripts across multiple machines or systems.

Difference between Selenium 3 and Selenium 4

Selenium 3 vs Selenium 4

Selenium 3.0

JSON wire protocol was used to communicate between the Selenium Webdriver APIs and the browser native APIs. All the requests and responses communicated across the protocol were encoded & decoded. 

Selenium 4.0

It follows the W3C standard protocol (driver and the browser communication follows the standard procedure) due to this request and the response communicated across the protocol doesn’t require the encoding and decoding API.

Selenium 4 Features:

Let’s see the new features of Selenium 4 Alpha which can be available in Selenium 4.0.

1. WebDriver changed to W3C Standardization

The major change in Selenium 4 is the standardization of the WebDriver API with respect to W3C standards to encourage compatibility across various software implementations. With this change, requests and responses communicated across the protocol don’t require the encoding and decoding API. Based on the W3C standards updation, any software that follows W3C standards can be integrated with Selenium 4 without any compatibility issues. Almost all browsers such as Chrome, Safari, and IE are already W3C standard compliant.

2. Selenium Grid Optimization

Even though Selenium Grid was developed long back in 2011. With Selenium 4, Selenium Grid is coming up with improvised UI and stability by removing the issues occurred in the earlier version of Grid like installation, the connection between the hub and node.

It allows us to execute the test cases in parallel on multiple operating systems, multiple browsers, and in different versions. 

The Grid UI is flexible, user friendly and information like session’s capacity, run time can be found in the UI.

Nodes can be multiple in a grid and these are used to execute test scripts on an individual systems. 

Hub can be used as a central point from where we can allocate test scripts execution to different nodes in the network. 

There is no need to set up to the start the hub & nodes individually once we start the server. The Grid automatically works as a hub and nodes. 

We can use Docker to spin up containers instead of users setting up heavy virtual machines. We can deploy it on Kubernetes for better scaling and self-healing capabilities. 

It also supports tools like AWS, Azure, and helps in the process of DevOps.

Check this link for more information on Selenium Grid

3. Relative Locators

Relative locators (aka Friendly locators) allow us to locate the web elements by its position by concerning other web elements such as above, below, toLeftOf, toRightOf, and near.

In simple words, relative locators allow us to locate web elements based on their position with respect to other web elements.

There are five locators newly added in Selenium 4:

  • above(): It is to locate a web element just above the specified element
  • below(): It is to locate a web element just below the specified element
  • toLeftOf(): It is to locate a web element present on the left of a specified element
  • toRightOf(): It is to locate a web element present on the right of a specified element
  • near(): It is to locate a web element at approx. 50 pixels away from a specified element. The distance can be passed as an argument to an overloaded method.

Note: Method “withTagName()” is added which returns an instance of RelativeLocator. Above relative locators support this method “withTagName()

Check out a detailed guide on Selenium Relative Locators

4. Multiple Tabs & Windows

With Selenium 4, we can work with multiple tabs or windows. We can open a new tab or window in the same session without creating a new driver object.

  • To create a new Tab by passing WindowType.TAB to newWindow() method
  • To create a new window by passing WindowType.WINDOW to newWindow() method

Note: To switch between the windows, we have to fetch the window IDs and pass it to the switchTo().window()

Tab:

Window:

5. Browsers Support

Native support has been removed for Opera and PhantomJS. Since the WebDriver implementations for these browsers are no longer under active development.

  • If you are an Opera user then you can use Chrome. 
  • If you are a PhantomJS user then you can use Chrome or Firefox in a headless mode.

6. Selenium IDE

Selenium IDE is a tool used to record and playback. It allows us to interact with browsers. The previous version of Selenium IDE was deprecated in the year 2017. The latest version of Selenium IDE is coming up with man more advanced capabilities. 

  • With better UI & user experience
  • It allows us to export code for all the official language bindings (Java, Python, JavaScript, .Net & Ruby)
  • CLI runner (Selenium-side-runner) which runs on NodeJs allows us to perform playback and parallel execution on multiple browsers.
  • It also provides reports with information like a total number of test cases executed with execution time, no. of test cases passed, and no. of test cases failed. 
  • It allows users to run on browsers like Firefox, Google Chrome, IE, etc.,

7. WebElement Screenshot

Selenium 3 allows users only to capture a webpage and no provision to capture screenshot of a specific web element. Selenium 4 allows us to take a screenshot of a particular web element.

8. Chrome DevTools

Selenium 4 has native support for Chrome DevTools protocol through the “DevTools” interface. With this, we can get Chrome Development Properties such as Application Cache, Fetch, Performance, Network, Profiler, Resource Timing, Security, and Target CDP domains, etc.,

Chrome DevTools is a set of web developer tools. These have been built directly to the Chrome Browser. It allows us to edit the web pages and diagnose problems quickly. This way we can make better websites and deliver it faster.

We will see Chrome DevTools in detail later.

9. Monitoring

Logging and request tracing processes have been improvised to fasten the debugging process which resolves the script issues easily.

10. Documentation:

Selenium 4 comes out with official and detailed documentation on Selenium IDE, Selenium WebDriver, and Selenium Grid.

Documentation of Selenium WebDriver is available and you can find it here.

Download Selenium 4

You can find Selenium 4 Alpha in the Maven repository. You can download it from Selenium official website

Selenium Downloads

Download Selenium 4 (Alpha 6) Maven Dependencies from here

Install Selenium 4

Please check this step by step Selenium 4 Installation Guide

What is deprecated in Selenium 4

Some of the methods deprecated in Selenium 4 are as follows

FindsBy

FindsBy interface is a part of org.openqa.selenium.internal package implemented by the RemoteWebDriver class. The methods in that are findElement(By), findElements(By).

Note: These changes won’t affect end users. You can use By class with findElement(By) and findElements(By).

Actions

The Actions class is used to emulate user gestures like mouse movements, hoverings etc., In the Selenium 4, some new methods have added to the Actions class as a replacement of the classes under org.openqa.selenium.interactions package.

click

click(WebElement) is a method to click an element. It is added newly to Actions class in replacement of moveToElement(onElement).click()

clickAndHold

clickAndHold(WebElement) is a method to click on an element without releasing. It is added to Actions class in repalcement of moveToElement(onElement).clickAndHold()

contextClick

contextClick(WebElement) is a method to right click on an element. It is added to Actions class in replacment of moveToElement(onElement).contextClick().

doubleClick

doubleClick(WebElement) is a method to double click on an element. It is added to Actions class in replacment of moveToElement(element).doubleClick().

release

release() is a method to release the depressed left mouse button at the current mouse location. release() is moved to Actions class from org.openqa.selenium.interactions.ButtonReleaseAction class.

Fluent Wait

The methods in the fluentwait such as withTimeout() and pollingEvery() have been modified.

Fluentwait in Selenium 3

FluentWait in Selenium 4

Selenium 4 replaced the TimeUnit with Duration

Driver Constructors

Few driver constructors have been deprecated. Capabilities objects have been replaced with Options.

We have to create an Options object for the Driver class we use.

FirefoxDriver

FirefoxDriver Capabilities is replaced by FirefoxDriver FirefoxOptions.

ChromeDriver

ChromeDriver Capabilities is replaced by ChromeDriver ChromeOptions.

InternetExplorerDriver

InternetExplorerDriver Capabilities is replaced by InternetExplorerDriver InternetExplorerOptions.

SafariDriver

SafariDriver Capabilities is replaced by SafariDriver SafariOptions.


EdgeDriver

EgdeDriver Capabilities is replaced by EdgeDriver EdgeOptions.

Conclusion

In this tutorial, we have covered new features of Selenium 4.0 such as W3C standardization, brand new Selenium IDE, Relative Locators, Multiple Tab/Windows, and others. We hope Selenium 4.0 gives us the best experience and ability to do almost all the tasks which are unfulfilled in Selenium 3.

Share your thoughts on these changes to Selenium in the comments section below.

Must read: Selenium Tutorial

Get our latest blog posts delivered to your inbox

Subscribe and get popular blog posts about software testing industry.

Rajkumar

Leave a Comment

Share via
Copy link
Powered by Social Snap