App & Browser Testing Made Easy

Give your users a seamless experience by testing on 3000+ real devices and browsers. Don't compromise with emulators and simulators

Get Started free
Home Guide How to upgrade from Selenium 3 to Selenium 4

How to upgrade from Selenium 3 to Selenium 4

Shreya Bose, Technical Content Writer at BrowserStack -

Since its announcement in 2018, Selenium 4 has been a point of excitement in the development and testing community. Naturally, devs and testers want to move to the newer version, because it offers a litany of new features and updates that provide very real advantages. 

For individuals looking to download and use the Alpha version of Selenium 4, a quick rundown of what this transition entails is necessary. The best place to start this discussion is a comparison between Selenium 3 vs Selenium 4. Let’s have a look at what has changed, and what Selenium users moving to version 4 have to do differently. 

Selenium 3 vs Selenium 4

Note: Part of the information here has been described in greater detail in the article on Selenium 4: Understanding Key Features.
  • Selenium WebDriver W3C Standardization

In Selenium 3, the JSON Wire Protocol facilitated communication between test code and the browser in question – which involved the unnecessary extra task of encoding and decoding API requests via the W3C protocol. The JSON Wire Protocol will be deprecated in Selenium 4.

In Selenium 4, the WebDriver utilizes the W3C standardization. Since most browser drives (chromedriver, geckodriver) do the same, it will let WebDriver communicate directly with the browser, doing away with the need for JSON Wire Protocol entirely. This will likely result in more stable cross browser tests via Selenium than in its previous architectures. 

Since the WebDriver implementation for Opera and PhantomJS is no longer being developed, native support for these browsers has been removed in Selenium 4. 

  • Enhanced Selenium 4 IDE

In Selenium 3 and older Selenium versions, the Selenium IDE was only available as a Firefox extension with limited features. 

In Selenium 4, the IDE has become available for widely used browsers such as Chrome (as a Chrome extension). It is also expected to become available as a plugin or web extension for MS Edge soon. The IDE in Selenium 4 is equipped with a SIDE tool (Selenium IDE Runner) which allows the execution of a .side project on a Node.js platform. The SIDE Runner is useful for running cross browser tests in the form of parallel testing on a cloud Selenium Grid such as the one provided by BrowserStack. 

Additionally, the IDE in Selenium 4 offers an Export feature that lets testers export recorded tests as code in languages supported by Selenium – C#, Python, Java,  JavaScript, .NET, etc. 

  • Optimized Selenium Grid

In  Selenium 3 and older, the Hub and Node (s) need to be initiated individually when performing automation testing. It supported the following processes – Router, Session Map, Distributor.

In Selenium 4, the Hub and Node are consolidated into a single jar file. Once the server starts, it activates both Hub and Node. The processes supported here are – Router, Session Map, Distributor, Node. It also comes with an enhanced GUI and support for Docker. 

The Selenium 4 Grid also supports IPV6 addressed, and facilitates user interaction with the Grid via HTTPS protocol. It also supports DevOps-friendly tools such as AWS and Azure. 

  • Support for Chrome DevTools

Unlike Selenium 3, Selenium 4 provides native support for Chrome DevTools Protocol through its DevTools interface. It allows testers to utilize Chrome Development Properties like Fetch, Network, Profiler, Performance, Application Cache, etc. APIs offered by Chrome DevTools help QAs and devs identify anomalies faster and edit code without interrupting its execution (on-the-fly). 

These APIs also help replicate myriad geographical locations and network strengths in Selenium 4 which enables QAs to run geolocation testing and test websites in throttled network conditions (2G, 3G, 4G, Edge) geolocation testing.

  • Relative Locators

Selenium 3 required testers to used findElement commands to locate web elements in the vicinity of another element, such as to the right/left/above/below of an element. 

Selenium 4 has implemented the ability to do exactly this. It has introduced Relative Locators that allow testers to find web elements relative to another element in the DOM. 

  • DesiredCapabilities

Selenium 3 used DesiredCapabilities to help QAs define basic test requirements such as operating systems, browser combinations, browser versions, etc. within Selenium test scripts.

In Selenium 4, DesiredCapabilities have been replaced by Options. To use the Driver class, QAs have to create an Options class, set test requirements, and pass the object to the Driver constructor.  

Driver constructors that accepted Capabilities objects have been replaced with those that accept Options. 

# ChromeDriver(Capabilities) replaced by ChromeDriver(ChromeOptions).

# SafariDriver(Capabilities) replaced by SafariDriver(SafariOptions).

# EgdeDriver(Capabilities) replaced by EdgeDriver(EdgeOptions).

# FirefoxDriver(Capabilities) replaced by FirefoxDriver(FirefoxOptions).

# InternetExplorerDriver(Capabilities) replaced by InternetExplorerDriver(InternetExplorerOptions).

  • Actions Class

A number of new methods have been added to the Actions class to replace classes previously contained within package org.openqa.selenium.interactions:

# click(WebElement) is added to Actions class to replace moveToElement(onElement).click(). It is used to click on a certain web element.

# clickAndHold(WebElement) added to replace moveToElement(onElement).clickAndHold(). It is used to click on an element without releasing the click. 

# contextClick(WebElement) added to replace moveToElement(onElement).contextClick(). It is used to right click on an element.

# doubleClick(WebElement) added to replace moveToElement(element).doubleClick(). It is used to double click on an element.

# release() was initially a part of org.openqa.selenium.interactions.ButtonReleaseAction class. Now it has been moved to Actions class. It is used to release the depressed left mouse click at the current cursor location. 

  • FluentWait

In Selenium 4, two methods from FluentWait withTimeout() and pollingEvery() now accept a single parameter – java.time.Duration. Previously, in Selenium 3,  they accepted two separate parameters int and TimeUnit

For the full list of deprecations in Selenium 4, visit the official Selenium site

How to upgrade to Selenium 4

The Selenium upgrade to 4 can be undertaken in multiple ways:

  • Selenium with Maven: Simply change the Selenium version from 3 to 4 in pom.xml.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""


<!-- -->




  • Selenium with Gradle: Change Selenium version to 4 as shown below: 
plugins {
id 'java'

group 'SeleniumGradleSample'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {

dependencies {
compile group: 'org.testng', name: 'testng', version: '6.14.3'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.0.0-alpha-6'

test {


  • Install Fresh Instance of Selenium 4: Ensure that Java is installed on the local machine. Additionally, set the JAVA_HOME environment variable in the system path. This can be done via build tools (Maven or Gradle, as detailed above) or manually. 

To accommodate the new version, BrowserStack has made necessary changes that would allow QAs to use Selenium 4 on its cloud Selenium grid

No matter the Selenium version, automation testing must be run on real browsers and devices to yield accurate results. Start running tests on 3000+ real browsers and devices on BrowserStack’s real device cloud. Run parallel tests to get faster results without compromising on accuracy. Detect the bugs and offer a high-end UX/UI to the users by automated testing in real user conditions with BrowserStack Automate.

Selenium Selenium Webdriver

Featured Articles

Shift from VMs to Selenium Grid on Cloud for Cross Browser Testing

Cross Browser Testing in Selenium : Tutorial

App & Browser Testing Made Easy

Seamlessly test across 20,000+ real devices with BrowserStack