Back to Resources

Blog

Posted October 29, 2021

Frequently Asked Questions About Selenium 4

quote

What are the Main Benefits of Using Selenium 4?

Standards-based protocol

Selenium 4 uses the W3C WebDriver standard protocol for browser automation. As browser vendors will only support W3C WebDriver in the future, using Selenium 4 ensures the widest possible range of support across all browsers, making your automation scripts future proof.

Relative locators

Selenium 4 relative locators are a 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.

New window and 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.

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.

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.

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.

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).

Do I Have to Change My Tests?

If you've already updated your Selenium 3 capabilities to be W3C compliant, your code should continue to work. Some of the language bindings have updated the recommended code for 4.0, however, so some minor changes might be desired. More details can be found in our Selenium 4 upgrade guide.

Will My Tests Still Run on Sauce Labs?

Tests will continue to run on our platform. However, if you are not doing it yet, Sauce Labs specific capabilities need to be placed inside the sauce:options block. With that, Sauce specific features for your tests (specifying browser versions, initiating secure tunnels, Extended Debugging, etc.), will continue to work well.

Examples showing how to create a sauce:options block can be seen in our Selenium 4 upgrade guide and in the Selenium section inside the Sauce Labs docs.

Sauce Labs is Here to Help

We encourage you to upgrade your tests to Selenium 4 and run them on our platform. Our upgrade Selenium 4 upgrade guide and Selenium documentation are available for your reference during the upgrade process. Go through them and let us know what you think by contacting us.

Mike Donovan
VP of Product, Sauce Labs
Published:
Oct 29, 2021
Share this post
Copy Share Link
© 2023 Sauce Labs Inc., all rights reserved. SAUCE and SAUCE LABS are registered trademarks owned by Sauce Labs Inc. in the United States, EU, and may be registered in other jurisdictions.