Extending Your Selenium Grid With Sauce
Sauce AI for Test Authoring: Move from intent to execution in minutes.|xBack to ResourcesBlogPosted
Sauce AI for Test Authoring: Move from intent to execution in minutes.
|
x
Blog
Extending Your Selenium Grid With Sauce
Keep your existing Grid, and automatically send overflow/different exam (e.g. Safari) to Sauce Labs!
If you ’ re apply Selenium to automatise your application ’ s UI tests, at some point, you ’ ll need to scale your testing. This means not only running trial on multiple platforms, browsers, and browser version, but also running tests in parallel, using either Selenium Grid or a cloud vendor like Sauce Labs. In the past this has been an either/or alternative, but hither we ’ ll show you how you can combine them!
Selenium Grid has been a native part of the Selenium project for more than 10 years. It ’ s mature, easy to adopt, and very versatile in its conformation. For little, nimble operation, a local Selenium Grid is a good starting point for test executing.
At some point, yet, go a Selenium Grid completely on-premise or in a self-managed cloud can become a real maintenance nightmare, so I ’ ll explicate how to unlade some of that headache to a managed cloud. Whether you want to hold some browser constellation locally, or you need to switch over to the cloud for all your needs, the Selenium Grid is flexible enough to do whatever you need.
Introducing: The Relay Node!
Selenium 4 saw a ground-up rewrite of the cardinal Selenium Grid architecture.Details are hither, but one of the most exciting features is the[relay] option.
This pick grant you to route Grid tests to another Grid, another network, or a cloud seller like Sauce Labs.
For instance, you could feature 10 Nodes running topically or on AWS, all handling Chrome requests. If you suddenly need to be able to run Safari, it would mostly be much easier to set up a Relay Node to Sauce Labs than it would be to set up a farm of Mac Minis on a nearby desk. To do this, you would go to Sauce ’ s sign-up page, get an automated testing plan, and start bunk one more Grid Node with a slight pinch to the config (details below).
More model of “ spillover ” to a cloud vender:
You receive 10 Nodes running locally, but suddenly you ’ re required to run 100 tests at a clip as other teams are onboarding and hoping to use your grid.
Your grid is running Chrome and Edge, but is just configure to run “ up-to-the-minute ”. Suddenly you need to reproduce an number in Chrome from 5 versions ago. Having a Relay Node would allow you to do this with no changes to your existing Grid.
You ’ ve decided to migrate to a cloud provider, but the transition itself might cause too much disruption to your CI/CD configuration. The Relay Node let you to make this one alteration, and keep those configurations running utterly.
You find that, over clip, it become more and more of a painfulness to proceed these Grid Nodes up-to-date and lead. With the Relay Node, you slowly transmigrate away from maintaining your own grid, and let the cloud guide over the work–while executing your tests in precisely the same way as before.
Architecture
Default Grid

Grid With Spillover/Relay Nodes

Configuration
As shown in the, Relay Nodes are easy to configure. You can either write a TOML file with the details, or send the options via bidding line. My preference is for TOML, so the undermentioned examples.
At the end of this subdivision, you should have everything you want to configure and run a Relay Node, to attach to your existing Grid Hub, and watch jobs start to execute on Sauce Labs. We will start by showing you how to set up a Grid on a individual machine, but if you ’ d like to add a Relay Node to your exist Hub, skip the following session.
Set Up the Hub
Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script.
If you don ’ t already hold one, First, you ’ ll demand to a Selenium Grid Hub. You ’ ll motivation to download theselenium-server jar file, then run the following command in your best-loved shell: $ java -jar selenium-server-4.4.0.jar hub
Once the hub is running, you ’ ll attach nodes to it.
Set Up Your Relay Node
1[server]2embrasure = 555534[node]5detect-drivers = false6max-sessions = 10078[relay]9url = & quot; https: //<SAUCE_USERNAME>:<SAUCE_ACCESS_KEY>@ ondemand.us-west-1.saucelabs.com/wd/hub & quot;10# browser/platform configurations available11configs = [12& quot; 100 & quot;, & quot; {\ & quot; browserName\ & quot;: \ & quot; chrome\ & quot;, \ & quot; platformName\ & quot;: \ & quot; Windows 11\ & quot;} & quot;,13& quot; 100 & quot;, & quot; {\ & quot; browserName\ & quot;: \ & quot; MicrosoftEdge\ & quot;, \ & quot; platformName\ & quot;: \ & quot; Windows 11\ & quot;} & quot;,14& quot; 100 & quot;, & quot; {\ & quot; browserName\ & quot;: \ & quot; firefox\ & quot;, \ & quot; platformName\ & quot;: \ & quot; Windows 11\ & quot;} & quot;,15& quot; 100 & quot;, & quot; {\ & quot; browserName\ & quot;: \ & quot; safari\ & quot;, \ & quot; platformName\ & quot;: \ & quot; macOS 10.15\ & quot;} & quot;16]17
Save this to a file called config-sauce.toml, and control that it (and other Grid config and scripts) are store in Version Control. We will invoke this config in a bash script, as delineate below.
Let ’ s break this down:
Under the [relay] section, we first lean the URL for the relay. This is where we specify the Cloud provider we wish to tie to, with the SAUCE_USERNAME and SAUCE_ACCESS_KEY in place
Using this URL will automatically route all contour that either don ’ t lucifer with any other Nodes, or mate other Nodes that are already at content for that conformation
Under configs, you list the act of threads (“ 100 ” in these exemplar) to create available for the configuration
After the turn of threads, you show the operating system, and an optional browser version for each line
Note:Setting each configuration adequate to the total number of ribbon available in your Sauce Labs contract makes sense here, even though it may look like you ’ ll be running 400 trial at once! In the above [node] section, you ’ ve set max-sessions to 100, which means that the Grid will proceed accurate control over how many threads are executed on this Node at the like time, and will ensure you do not go over.
Start the Node
The easygoing way to start this Node is with a unproblematic command line (this assumes knock):
java -jar selenium-server-4.5.0.jar standalone -- config config-sauce.toml
You ’ ll likely want to save this to a shell handwriting, and version control it with the rest of your configs.
Considerations
If this node is always escape a certain kind of browser (e.g., Chrome), and you ’ re not capable to execute your Safari tests quickly, then it makes sense to lour the bit of threads uncommitted to the Chrome configuration (or remove the line entirely). You ’ ll get to run through several iterations of this as you get by in order to tweak and tune it to be optimal.
If need be, you can yet make multiple Relay Nodes that map to multiple cloud marketer or other Grids! The beauty of the Relay Node is its flexibility, and the fact that you entirely change contour on the Grid side, not on the trial framework or CI/CD side. This let you to track any constellation alteration in version control, and it altogether separate your product functionality from any contractual or cost issue within your trial infrastructure.
Mobile
Relay Nodes can likewise be extended to include Mobile testing, with Appium. Since Appium also adheres to the W3C WebDriver protocol, mobile tests can be attach to and accomplish by the same Grid, on Sauce. This removes even more of your upkeep burden as compared to a normal Grid, as wandering devices are much more maintenance-intensive than browser horde.
1configs =[2& quot; 5 & quot;, "{3\ & quot; browserName\ & quot;:\ & quot; chrome\ & quot;,4\ & quot; platformName\ & quot;:\ & quot; android\ & quot;,5\ & quot; appium:platformVersion\ & quot;: \"11\"6}"7]8
Give it a try!
Conclusion
The Relay Node is a tremendous, sorely postulate feature for the Selenium Grid. It let you to progress out a Grid that will acquire as your needs evolve, and it give you an easy itinerary for other teams to adopt your test base as your organization matures.
Test Strategist
Share this post
Need to test right now? Get started free.
Ship code that behaves just as it should, quicker.
Automate This With SUSA
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.
Try SUSA FreeTest Your App Autonomously
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.
Try SUSA Free