Selenium 4 Grid Architecture
Selenium 4 Grid Architecture
In this tutorial, let’s examine the Selenium 4 Grid Architecture. Selenium Grid is a tool that allows you to run automated tests on multiple machines and browsers simultaneously. It acts as a central hub to distribute test execution across different environments, saving time and resources.
Selenium 4 Grid Components
In Selenium 4, the Grid components are modularized and use a distributed model. Selenium grid components in the 4 version are as follows:
- Router: Entry point for all requests
- Distributor: Manages node registration and test distribution
- Session Map: Tracks active test sessions
- Node: Machines where browsers run
- Event Bus: Communication channel between components
- New Session Queue: Holds incoming test requests
The components work together and interact with each other in distributed mode to scale and distribute Selenium tests on different browsers and machines.
The Grid Architecture is displayed below.
Selenium Grid 4 introduced several UI enhancements compared to its predecessor, Selenium 3. These improvements are part of a broader modernization effort in Selenium 4, focusing on usability and ease of configuration.
Grid Architecture Explained
The Selenium 4 Grid uses a modular architecture where components communicate through an Event Bus.
Router
Acts as the front door. Receives all HTTP requests and routes them to appropriate components (new sessions go to New Session Queue, existing sessions go to Nodes).
Distributor
Registers Nodes and assigns tests to them based on browser requirements and Node availability.
Nodes
Remote machines with browser installations. Execute tests and report back results. Can run different browsers/versions.
Session Map
Maintains a registry of active test sessions. Helps Router direct commands to correct Nodes.
Event Bus
Acts as a nervous system. Enables components to communicate without direct dependencies using messages/events.
New Session Queue
Stores incoming test requests in FIFO order. Prevents overload by queuing requests when all Nodes are busy.
To know more about the Selenium Grid Distributed Mode:
Test Work Flow
The test workflow is as follows:
- Test request → Router → New Session Queue
- Distributor picks request and finds matching Node
- Session Map records session details
- Router directs subsequent commands to Node
- Node executes commands and returns results
Related