Back to Resources

Blog

Posted October 20, 2021

Selenium 4 - Updates to Selenium Grid

Selenium Grid 4 has been rewritten from scratch, with all the learnings from the past, plus it takes advantage of modern infrastructure (such as Docker and distributed tracing).

quote

Selenium Grid is one of the Selenium projects, which enables users to run tests in parallel by distributing them across different hosts, specifying different operating systems and browsers. Selenium Grid 4 has been rewritten from scratch, with all the learnings from the past, plus it takes advantage of modern infrastructure (such as Docker and distributed tracing).

More details about the Grid rewrite can be found in this blog post written by Selenium Project lead Simon Stewart. To see the new Selenium Grid in action, you may also want to check out this Appium Conference 2021 talk. The best way to get started with Selenium Grid 4 is to follow the official documentation from the Selenium project.

If you are familiar with Selenium Grid, what may be of particular interest to you is that you can now extend a local Selenium Grid instance to access capabilities and see test results on Sauce Labs. Selenium Grid 4 has a feature that allows you to relay commands to a service that supports WebDriver. This fits well in the case where a Grid running locally only supports Windows but there is the need to run tests in Safari.

To see this in action, we start with a sample configuration file for a stand-alone server. The configuration has the Sauce Labs endpoint to create new sessions, and the supported stereotypes. In this case, we are telling Selenium Grid to forward all requests for Safari 14 and 15 to Sauce Labs.

[node] detect-drivers = false [relay] # Sauce Labs endpoint url = "https://yourUserName:yourAccessKey@ondemand.us-west-1.saucelabs.com:443/wd/hub" status-endpoint = "/status" # Stereotypes supported by the service configs = [ "1", '{"browserName": "safari", "browserVersion": "14", "platformName": "macOS 11.00"}', "1", '{"browserName": "safari", "browserVersion": "13", "platformName": "macOS 10.15"}' ]

Save the configuration shown above in a file called config.toml. Next, download the selenium-server-4.0.0.jar file from the Selenium repository. To finalize the set up, start the Grid by running the following command on the same directory where the config.toml file is:

java -jar selenium-server-4.0.0.jar standalone --config config.toml

After that, you will see in the log how the Sauce Labs endpoint was recognized and is ready to match requests for Safari.

Sauce To Go

If you are looking to enhance your local Grid, and benefit from the wide range of features offered by Sauce Labs. Check out this new experiment implemented by our Open Source Program Office.

Check out our comprehensive guide to Selenium 4 for more information.

Diego Molina
Staff Software Engineer at Sauce Labs
Published:
Oct 20, 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.