Selenium Grid is part of the Selenium suite of tools designed to enable parallel test execution on multiple machines and browsers simultaneously. With a grid you can distribute test execution across different environments, for example different Windows, macOS or Linux machines. The grid provides a scalable solution for running tests in parallel (simultaneously) across various (virtual) machines.
Selenium Grid consists of two main components
- Hub: This is the central server, responsible for forwarding test requests to the correct Selenium nodes.
- Node(s): A node is a single machine that is capable of running a browser test, for example a Windows/macOS/Linux machine.
The Selenium Hub
The Selenium Grid hub is a central server that manages and coordinates the test execution on different nodes.
The TestingBot service is running a central hub (https://hub.testingbot.com), which is responsible for forwarding test requests to the correct Selenium nodes, running in the TestingBot cloud.
A Selenium Hub can be started with a simply java command in your terminal:
Selenium Nodes
Nodes are machines or devices where the actual test execution takes place. Nodes register with the hub, indicating the browsers and platforms they can run Selenium tests on.
Usually, a Selenium grid consists of multiple nodes. Most people would add one or more nodes with a Windows operating system and one or more nodes with macOS. This way they can test on the most popular browsers:
To set up a node, make sure you have Java 11 or higher installed on each OS that you want to use as Node.
Each node should have enough CPU (cores) and RAM (memory) to be able to both run the Selenium Node's Java process as well as instruct the browser. Browsers can use up a lot of memory, so be sure to provision enough RAM for each node.
To start a node, you can use the following command in your terminal
- Chrome on Windows and macOS
- Edge on Windows and macOS
- Firefox on Windows and macOS
- Safari on macOS
Once multiple nodes are registered to the hub, the hub will know which test requests it needs to redirect to which Selenium nodes, by comparing the desired capabilities of the test script with the registered capabilities of each of the Selenium nodes.