• Selenium Video Tutorials

Selenium Grid - Components



The latest version of Selenium Grid is on version 4. The earlier versions of Selenium Grid were available in versions 1 and 2. The latest version of Selenium Grid 4, is developed newly without leveraging the code base of the older versions of Selenium Grid.

The Selenium Grid version 4 has a lot of improvements and is more compliant from the previous versions of Selenium Grid. The various features of the Selenium Grid are made more granular to make it as per the latest software development trends.

The latest version of Selenium Grid allows test execution to be triggered in three different Selenium Grid modes. They are known as the Standalone, Hub and Nodes, and the Distributed.

Different Components of Selenium Grid

The different components of Selenium Grid are listed below −

  • Router

  • Distributor

  • Node

  • Session Map

  • Session Queue

  • Event Bus

Router in Selenium Grid

The Router is the starting section of the Selenium Grid. It gets all the requests and directs them to the right place. In case, a new session request is given to the Router, the New Session Queue will receive that from the Router. For an existing session request, the Router will query the Session Map to obtain the Node ID, which holds the id of the existing session. Finally, the request is sent directly to the Node.

A Router is instrumental to maintain the proper load balance in the Selenium Grid by dispatching the request to a suitable Selenium Grid component so that an optimal balance is maintained without overloading any component.

Distributor in Selenium Grid

The Distributor takes care of registering and managing all the Nodes and their features. A Node is registered by the Distributor by directing a Node registration event with the help of the Event Bus. The Distributor accesses it and makes an attempt to reach the Node using HTTP to confirm its presence. If the presence is confirmed, the Node is registered by the Distributor and all its features are tracked by the Distributor with the help of the GridModel.

In case, a new session request is given to the Router, the New Session Queue will receive, and stay in the queue. There is a polling done by the Distributor for the New Session Queue for the rest of the new unresolved session requests. Once a proper opportunity has been available, the Distributor assigns a proper Node where a session can be started. Once a session is kicked off, the Distributor maintains the Session Map(which is the connection between the session id and the Node where the session is being run).

Session Map in Selenium Grid

The Session Map is storage that saves the connection between the session id and the Node where the session is executing. The Session Map helps the Router in directing the request to the Node. The Router will also request the Session Map for the Node related to the session id.

New Session Queue in Selenium Grid

The New Session Queue stores all the session requests in the First In First Out Order. The request timeouts and period in which the timeout is verified can be configured.

The Router appends the new session request to the New Session Queue and awaits its response. The New Session Queue keeps checking if any request in the queue has timed out. If there is a timeout, that request is not accepted and separated straightaway.

The Distributes keeps track of any available slots. Once it is present, the Distributor starts polling the New Session Queue for any matching request, later it tries to begin a session.

Once there is a match of the requirements and features of any Node which is currently idle, the Distributor grabs that. If all the suitable Nodes are busy, the Distributor redirects the request to the queue. If the request is timed out while waiting in the queue, the request is not accepted any more.

Once a session has begun properly, the Distributor forwards the session details to the New Session Queue, which is sent back to the router, and lastly to the client.

Node in Selenium Grid

Selenium Grid consists of more than one Node. The Node keeps track of all the obtainable browsers within the machine where it is being used. The Node is registered to the Distributor with the help of the Event Bus. After registration, a registration message is sent containing the configuration details.

The Node registers all the browser drivers present in the proper path in the machine by default. It also generates the slot in the CPU for different browsers like Chrome, Firefox, Safari, and so on. The configurations can be set such that sessions can be run on the Docker containers and relay commands.

A Node only runs the commands and responses it has got and manages its flow, it is unable to process, or verify those commands. The operating system configured in Nodes may or may not be the same.

Event Bus in Selenium Grid

The Event Bus takes care of the connection path among the Nodes, New Session Queue, Distributor, and the Session Map. In the Selenium Grid, the communication happening among each of the components are done in the form of messages and not with the help of HTTP requests and responses. While initiating a session in Selenium Grid in a distributed system, the Event Bus should be kicked off at the beginning.

The interaction between various components of Selenium Grid is shown in the below diagram −

Selenium Grid Components

This concludes our comprehensive take on the tutorial on Selenium Grid - Components. We’ve started with describing what are the different components of Selenium Grid, what is a Router, Distributor, Session Map, Node, and Event Bus in Selenium Grid.

This equips you with in-depth knowledge of the Selenium Grid Components. It is wise to keep practicing what you’ve learned and exploring others relevant to Selenium to deepen your understanding and expand your horizons.

Advertisements