Several new features and benefits for automated testing are included in the upcoming Selenium 4 release, such as:
Better window and tabs managing
Improved Selenium Grid
Use of W3C by default under the hood
A set of bidirectional APIs designed for intercepting network requests, authentication on secure pages, listening to DOM events and more. These are currently implemented through the Chrome DevTools Protocol (CDP), but in the future WebDriver BiDi will be used.
Selenium 4 has been designed to be a drop-in replacement, but there might be cases where tests or dependencies need to be adjusted. We recommend you to go through the following sections to understand better how this new version will benefit you and what potential changes might be needed to upgrade.
Sauce Labs has contributed to the development of Selenium 4, and thanks to that, you can rest assured that your tests will continue to work on our platform.
How to upgrade to Selenium 4
The Selenium team has spent a good amount of time making the upgrade process as painless as possible. A few things have been deprecated, so you might hit a couple of issues while upgrading, especially if you have built custom functionalities in your testing framework. This guide will show you how to move from Selenium 3 to Selenium 4.
A new way of locating elements by using more natural language friendly terms, such as “above”, “below”, “left of”, “right of”, and “near”. In general, you could think about them as a way to locate elements based on the visual placement on the page. Check how to use the new Relative Locators here.
New Window & Tab utilities
Selenium 4 includes a new command to help users create a new tab or a new window. Check some code examples that show how to use it.
Print Page as PDF
Selenium 4 will allow users to print a page as a PDF through Chrome and Firefox. Examples with each browser can be seen here.
New features with Firefox
The upcoming version of Selenium exposes a few new features with Firefox, such as a full page screenshot, a simplified way to install add-ons, and updating Firefox preferences in the middle of the session. Check them here.
Setting network conditions with Chrome and Edge
Selenium 4 exposes a set of utilities to modify the network conditions in Chromium based browsers, useful to test web applications under different network conditions. Check the details here.
New Element Attribute and Property methods
Two new methods have been added to more precisely get a given element attribute or a property. It is recommended to use one of the new methods for performance and preciseness, specially if you are using Sauce Labs. Read more about them here.
New Selenium Grid
Selenium Grid 4 has been rewritten from scratch, with all the learnings from the past. It takes advantage of modern infrastructure (such as Docker and distributed tracing). Read more details about it here.
Selenium 4 offers new functionality useful for both browser automation and testing, specifically with a set of bidirectional APIS. Through it, you will get more information from the browser and more control over the application under test. While the WebDriver BiDirectional Protocol is getting implemented across all browser vendors, these features will be offered through the Chrome DevTools Protocol (CDP). Check some examples that show how to use it here.
Frequently Asked Questions
Check a list of the most commonly asked questions about the upcoming Selenium version here.
| Header |
| ---------- |
| Cell |
| Cell |