Selenium Grid

Selenium Grid is another component of Selenium Suite which is used for Parallel Execution of test cases on different machines.

Execution is possible on different machines with different browsers or same browser but different versions at the same time.

Selenium Grid

In this tutorial, we will learn how to create a network to execute parallel testing using the grid. This setup consists of a Hub and multiple nodes. Hub is a central point which controls all the nodes. Nodes are the actual machines on which execution is done.

Configuration of Selenium Grid:

Selenium Grid comes bundled with Selenium WebDriver. One single jar file i.e. Selenium-server-standalone-2.xx.x.jar is sufficient.

Steps to configure Selenium Grid Setup:

  1. Start a machine as a Hub which will behave like a central point to control all the nodes.
  2. Start all the nodes and register them on above hub.
  3. Start executing code on these nodes.

Starting a Hub:

  • Hub can be started using server jar file, from command prompt using below command on any platform be it Windows, Linux or Mac
java - jar selenium-server-standalone-2.53.1.jar - role hub

First, navigate to the path where you have kept the Selenium jar and then execute the above command. This will register your machine as a hub. See the screenshot below for your reference:


There is another way of verifying that grid is registered successfully as Hub. Navigate to “http://localhost:4444” and verify that you see below image.

Verify grid as hub

Configuring a Node:

Nodes are the system on which test cases has to be executed. This system can be a local machine or a remote machine.

Node can be started using server jar file, from command prompt using below command on any platform be it Windows, Linux or Mac

java - jar selenium-server-standalone-2.53.1.jar - role node -hub

This will register a node on a hub. See the below screenshot for your reference.

Grid Registered as node

Here, one point to be noted is that by default HUB uses 4444 port to listen to a new request. This port can be changed by passing an attribute called -port=<port value>.

Note: Turn off the firewall while running hub and nodes otherwise you may get connection errors.

Once the node gets registered to the hub you will get a message on the console (Please refer above image for same).

There is another way to verify that nodes are successfully registered to the hub. Navigate to “http://localhost:4444/grid/console” and verify below image:


Now, let’s execute a call flow:

To execute a call flow using Selenium Grid, we will be needing objects of DesiredCapabilities and RemoteWebDriver.

DesiredCapabilities is used to set the browser and RemoteWebDriver is used to set on which node test case will be executed.

Refer the code below:

package day9;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class ExecutingGrid {

	public static void main(String[] args) throws MalformedURLException {
		DesiredCapabilities capabilities = DesiredCapabilities.firefox();
		URL url = new URL("");
		WebDriver Driver = new RemoteWebDriver(url, capabilities);


This code will execute the code on a machine with IP “” on firefox browser and will invoke “” site.

For any questions, queries or comments feel free to write us at or Happy Learning ?

Saurabh Dhingra

About the Author

Saurabh Dhingra

Follow Saurabh Dhingra: