---
description: Selenium Grid is a part of the Selenium Suite that specializes in running multiple tests across different browsers, operating systems, and machines in parallel.
title: Selenium Grid Tutorial: Setup a Hub and Node
image: https://www.guru99.com/images/selenium-grid-tutorial.png
---

 

[Skip to content](#main) 

**⚡ Smart Summary**

Selenium Grid runs multiple tests across browsers, operating systems, and machines in parallel using a hub-and-node architecture. The hub loads tests on one machine while nodes execute them on others, enabling faster cross-browser coverage through command line or JSON configuration.

* 🧩 **Grid Defined:** Runs tests across browsers, OSes, and machines in parallel via a hub and nodes.
* 🎯 **Hub:** The single central machine where you load tests; only one hub per grid.
* 🖥️ **Nodes:** One or more machines that actually execute the tests on different platforms.
* ⚙️ **Setup:** Launch the Selenium Server jar with -role hub and -role node, or use a JSON config file.
* 🧪 **Test Scripts:** Use DesiredCapabilities and RemoteWebDriver to target a browser, OS, and node.
* ⏱️ **When to Use:** Broad browser-OS compatibility checks and faster parallel suite execution.

[ Read More ](javascript:void%280%29;) 

![Selenium Grid Tutorial](https://www.guru99.com/images/selenium-grid-tutorial.png)

## What is Selenium Grid?

**Selenium Grid** is a part of the Selenium Suite that specializes in running multiple tests across different browsers, operating systems, and machines in parallel. It is achieved by routing the commands of remote browser instances where a server acts as a hub. A user needs to configure the remote server in order to execute the tests.

Selenium Grid has 2 versions – the older Grid 1 and the newer Grid 2\. We will only focus on Grid 2 because Grid 1 is gradually being deprecated by the Selenium Team.

## Selenium Grid Architecture

Selenium Grid has a Hub and Node Architecture.

[](https://www.guru99.com/images/hub%5Fand%5Fnodes.jpg)

Selenium Grid Architecture

### Hub

* The hub is the central point where you load your tests into.
* There should only be one hub in a grid.
* The hub is launched only on a single machine, say, a computer whose OS is Windows 7 and whose browser is IE.
* The machine containing the hub is where the tests will be run, but you will see the browser being automated on the node.

### Nodes

* Nodes are the Selenium instances that will execute the tests that you loaded on the hub.
* There can be one or more nodes in a grid.
* Nodes can be launched on multiple machines with different platforms and browsers.
* The machines running the nodes need not be the same platform as that of the hub.

Selenium Grid uses a hub-node concept where you only run the test on a single machine called a **hub**, but the execution will be done by different machines called **nodes**. 

## How to Set Up Selenium Grid?

In this section, you will use 2 machines. The first machine will be the system that will run the hub while the other machine will run a node. For simplicity, let us call the machine where the hub runs as “Machine A” while the machine where the node runs will be “Machine B.” It is also important to note their IP addresses. Let us say that Machine A has an IP address of 192.168.1.3 while Machine B has an IP of 192.168.1.4.

**Step 1)** Download the Selenium Server from [here](https://www.selenium.dev/downloads/).

[](https://www.guru99.com/images/selenium-grid-setup-1.png)

**Step 2)** You can place the Selenium Server .jar file anywhere in your hard drive. But for the purpose of this tutorial, place it on the C drive of both Machine A and Machine B. After doing this, you are now done installing Selenium Grid. The following steps will launch the hub and the node.

**Step 3)**

* We are now going to launch a hub. Go to Machine A. Using the command prompt, navigate to the root of Machine A’s – C drive, because that is the directory where we placed the Selenium Server.
* On the command prompt, type **java -jar selenium-server-standalone-2.30.0.jar -role hub**
* The hub should successfully be launched. Your command prompt should look similar to the image below.

[](https://www.guru99.com/images/launch%5Fhub.jpg)

**Step 4)** Another way to verify whether the hub is running is by using a browser. Selenium Grid, by default, uses Machine A’s port 4444 for its web interface. Simply open up a browser and go to `http://localhost:4444/grid/console`

[](https://www.guru99.com/images/view%5Fhub%5Ffrom%5Fbrowser.jpg)

Also, you can check if Machine B can access the hub’s web interface by launching a browser there and going to where “iporhostnameofmachineA” should be the IP address or the hostname of the machine where the hub is running. Since Machine A’s IP address is 192.168.1.3, then on the browser on Machine B you should type `http://192.168.1.3:4444/grid/console`

**Step 5)**

* Now that the hub is already set up, we are going to launch a node. Go to Machine B and launch a command prompt there.
* Navigate to the root of Drive C and type the code below. We used the IP address 192.168.1.3 because that is where the hub is running. We also used port 5566 though you may choose any free port number you desire.
* NOTE: You now have to give path to the Gecko driver if using Firefox. Here is updated code that needs to be used

java -Dwebdriver.gecko.driver="C:\geckodriver.exe" -jar selenium-server-standalone-3.4.0.jar -role webdriver -hub http://192.168.1.3:4444/grid/register -port 5566

[](https://www.guru99.com/images/grid%5F2%5Flaunch%5Fnode.png)

* When you press Enter, your command prompt should be similar to the image below.

[](https://www.guru99.com/images/after%5Fnode%5Fis%5Flaunched.jpg)

**Step 6)** Go to the Selenium Grid web interface and refresh the page. You should see something like this.

[](https://www.guru99.com/images/view%5Fnode%5Ffrom%5Fbrowser.jpg)

At this point, you have already configured a simple grid. You are now ready to run a test remotely on Machine B.

### RELATED ARTICLES

* [XSLT Report in Selenium Webdriver ](https://www.guru99.com/xslt-report-selenium.html "XSLT Report in Selenium Webdriver")
* [Flash Testing with Selenium WebDriver ](https://www.guru99.com/flash-testing-selenium.html "Flash Testing with Selenium WebDriver")
* [How to Find Broken Links in Selenium ](https://www.guru99.com/find-broken-links-selenium-webdriver.html "How to Find Broken Links in Selenium")
* [Selenium VBA Excel Tutorial (Chrome Web Scraping) ](https://www.guru99.com/excel-vba-selenium.html "Selenium VBA Excel Tutorial (Chrome Web Scraping)")

## When to Use Selenium Grid?

You should use Selenium Grid when you want to do either one or both of following:

* **Run your tests against different browsers, operating systems, and machines all at the same time.** This will ensure that the application you are[ Testing ](https://www.guru99.com/software-testing.html)is fully compatible with a wide range of browser-O.S combinations.
* **Save time in the execution of your test suites**. If you set up Selenium Grid to run, say, 4 tests at a time, then you would be able to finish the whole suite around 4 times faster.

## Grid 1.0 Vs Grid 2.0

Following are the main differences between Selenium Grid 1 and 2.

| Grid 1                                                                                                                     | Grid 2                                                           |
| -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| Selenium Grid 1 has its own remote control that is different from the Selenium RC server. They are two different programs. | Selenium Grid 2 is now bundled with the Selenium Server jar file |
| You need to install and configure[ Apache ](https://www.guru99.com/apache.html)Ant first before you can use Grid 1.        | You do not need to install Apache Ant in Grid 2.                 |
| Can only support Selenium RC commands/scripts.                                                                             | Can support both Selenium RC and WebDriver scripts.              |
| You can only automate one browser per remote control.                                                                      | One remote control can automate up to 5 browsers.                |

Selenium grid can be set up in two different ways; one through command line and the other through JSON config file.

## Designing Test Scripts That Can Run on the Grid

To design test scripts that will run on the grid, we need to use **DesiredCapabilites** and the **RemoteWebDriver** objects.

* **DesiredCapabilites** is used to set the type of **browser** and **OS** that we will automate.
* **RemoteWebDriver** is used to set which node (or machine) that our test will run against.

To use the **DesiredCapabilites** object, you must first import this package

[](https://www.guru99.com/images/import%5Fdesired%5Fcapabilites.png)

To use the **RemoteWebDriver** object, you must import these packages.

[](https://www.guru99.com/images/import%5FRemoteWebDriver.png)

## Using the DesiredCapabilites Object

Go to the Grid’s web interface and hover on an image of the browser that you want to automate. Take note of the **platform,** and the **browserName** showed by the tooltip.

[](https://www.guru99.com/images/ToolTip%281%29.png)

In this case, the platform is “XP” and the browserName is “Firefox.”

We will use the platform and the browserName in our WebDriver as shown below (of course you need to import the necessary packages first).

[](https://www.guru99.com/images/DesiredCapabilities%5Fcode.png)

## Using the RemoteWebDriver Object

Import the necessary packages for RemoteWebDriver and then pass the DesiredCapabilities object that we created above as a parameter for the RemoteWebDriver object.

[](https://www.guru99.com/images/RemoteWebDriver%5Fcode.png)

## Running a Sample Test Case on the Grid

Below is a simple WebDriver[ Testng ](https://www.guru99.com/all-about-testng-and-selenium.html)code that you can create in Eclipse on Machine A. Once you run it, automation will be performed on Machine B.

import org.openqa.selenium.*;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.*;

public class Grid_2 {
 WebDriver driver;
 String baseUrl, nodeURL;
 @BeforeTest
 public void setUpWthrows MalformedURLException {
 baseUrl = "http://newtours.demoaut.com/";
 nodeURL = "http://192.168.1.4:5566/wd/hub";
 DesiredCapabilities capability = DesiredCapabilities.firefox();
 capability. setBrowserName("firefox");
 capability. setPlatform(Platform.XP);
 driver = new RemoteWebDriver(new URL(nodeURL), capability);
}
@AfterTest
public void afterTest() {
 driver.quit();
 }
@Test
public void simpleTest() {
driver.get(baseUr1);
 Assert.assertEquas("Welcome: Mercury Tours", driver.getTitle()); }
}

**The test should pass.**

| [](https://www.guru99.com/images/result%5F1.png) | [](https://www.guru99.com/images/result%5F2.png) |
| ------------------------------------------------ | ------------------------------------------------ |

## Selenium grid configuration using JSON File

JSON stands for Javascript Object Notation. It is a standard format used for interchange of data between browser and the web server. Selenium has an in-built JSON config file that can be used to set up selenium grid.

Below are the steps to configure selenium grid using JSON config file.

**Step 1)** Download the code for JSON config file using the below path

<https://github.com/SeleniumHQ/selenium/blob/selenium-3.141.59/java/server/src/org/openqa/grid/common/defaults/DefaultHub.json>

**Here is the code**

{
	  "port": 4444,
	  "newSessionWaitTimeout": -1,
	  "servlets" : [],
	  "withoutServlets": [],
	  "custom": {},
	  "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
	  "registryClass": "org.openqa.grid.internal.DefaultGridRegistry",
	  "throwOnCapabilityNotPresent": true,
	  "cleanUpCycle": 5000,
	  "role": "hub",
	  "debug": false,
	  "browserTimeout": 0,
	  "timeout": 1800
}

**Step 2)** Copy and paste the code on a text editor such as Notepad with the extension ‘.json’

**Step 3)** Launch the hub using the below command using command prompt

java -jar selenium-server-standalone-2.53.1.jar -role hub -hubConfig hubconfig.json

**NOTE:** Selenium stand alone jar file and the json file must be present on the same directory

**Step 4)** The below screen will appear which indicates the hub is set up successfully

[](https://www.guru99.com/images/1/selenium%5Fgrid%5F11.png)

**Step 5)** Open web browser and try connecting to the below URL

http://192.168.43.223:4444/grid/console

**NOTE:** The URL may vary from machine to machine. URL followed by ‘Nodes should register to’ on the above screen must be used.

**Step 6)** Grid Console screen will appear which indicates the hub is up and running

[](https://www.guru99.com/images/1/selenium%5Fgrid%5F12.png)

## Configure NODES using JSON

**Step 1)** Download the sample node configuration file provided by Selenium using the below URL

<https://github.com/SeleniumHQ/selenium/blob/selenium-2.53.0/java/server/src/org/openqa/grid/common/defaults/DefaultNode.json>

**NOTE:** IF YOU ARE USING SELENIUM 3.0 OR ABOVE, THE BELOW JSON FILE MUST BE USED

<https://github.com/SeleniumHQ/selenium/blob/selenium-3.141.59/java/server/src/org/openqa/grid/common/defaults/DefaultNodeWebDriver.json>

**Step 2)** Copy and paste the code into a text editor such as Notepad and save the file with the extension ‘.json’

**Step 3)**

Run the below command on command prompt

Java-Dwebdriver.chrome.driver="chromedriver.exe" -Dwebdriver.ie.driver="IEDriverServer.exe" -Dwebdriver.gecko.driver="geckodriver.exe" -jar selenium-server-standalone-2.53.1.jar -role node -nodeConfig node1.json

**NOTE:** Before running the command, please make sure the drivers for each of the browsers have been downloaded onto local machine directory

**Step 4)** The below screen will appear when enter key is pressed

[](https://www.guru99.com/images/1/selenium%5Fgrid%5F13.png)

**Step 5)** Navigate to the grid console to verify if the nodes have been successfully configured

[](https://www.guru99.com/images/1/selenium%5Fgrid%5F14.png)

The browsers are displayed on the grid console. Hence we can be sure that nodes are configured successfully.

**Sample Test Cases On Selenium Grid:**

 package com.objectrepository.demo;
 import org.openqa.selenium.*;
 import org.openqa.selenium.remote.DesiredCapabilities;
 import java.net.MalformedURLException;
 import java.net.URL;
 import org.openqa.selenium.remote.RemoteWebDriver;
 import org.testng.Assert;
 import org.testng.annotations.*;

 public class SeleniumGrid {

     WebDriver driver;
     String baseURL, nodeURL;

     @BeforeTest
     public void setUp() throws MalformedURLException {
         baseURL = "https://demo.guru99.com/test/guru99home/";
         nodeURL = "http://192.168.43.223:5566/wd/hub";
         DesiredCapabilities capability = DesiredCapabilities.chrome();
         capability.setBrowserName("chrome");
         capability.setPlatform(Platform.WIN10);
         driver = new RemoteWebDriver(new URL(nodeURL), capability);
     }

     @AfterTest
     public void afterTest() {
         driver.quit();
     }
     @Test
     public void sampleTest() {
         driver.get(baseURL);


         if (driver.getPageSource().contains("MOBILE TESTING")) {
             Assert.assertTrue(true, "Mobile Testing Link Found");
         } else {
             Assert.assertTrue(false, "Failed: Link not found");
         }

     }

 }

The above code launches chrome browser and navigates to the URL specified in the ‘baseURL’ variable. It verified a link name ‘Mobile Testing’ is displayed on the page

URL on the ‘nodeURL’ variable can be modified to reflect the IP Address of the remote machine. Test result can be verified on the default TestNG report generated

## FAQs

🔀 What is the difference between a hub and a node in Selenium Grid?

The hub is the single central machine where you load tests and manage the grid. Nodes are the machines that actually run the tests on specific browser and OS combinations. A grid has one hub and one or more nodes.

⚖️ What is the difference between Selenium Grid 1 and Grid 2?

Grid 1 uses a separate remote control and requires Apache Ant, supporting only Selenium RC scripts and one browser per control. Grid 2 is bundled with the Selenium Server jar, needs no Ant, and supports both RC and WebDriver scripts.

🧪 How do you run a test on a specific browser using Selenium Grid?

Create a DesiredCapabilities object, set its browserName and platform, then pass it to a RemoteWebDriver pointed at the node’s URL. The grid routes the test to a matching node for that browser and OS.

🤖 How does AI improve Selenium Grid test execution?

AI can prioritize and parallelize test runs, predict flaky tests, balance load across nodes, and self-heal broken locators. This reduces execution time and maintenance effort on large grids running many browser-OS combinations.

🧠 Can AI help configure and scale a Selenium Grid?

Yes. AI tools can recommend optimal node counts, generate JSON configurations, auto-scale cloud grids based on queue length, and detect underused capacity, helping teams run large suites efficiently without manual tuning.

#### Summarize this post with:

ChatGPT Perplexity Grok Google AI 

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.** 

##### Sign up for the newsletter

Subscribe for Free 

You have successfully subscribed.  
Please check your inbox. 

![AI-Newsletter]() Chosen by over **350,000+** professionals 

[Scroll to top ](#wrapper)Scroll to top 

× 

Toggle Menu Close 

Search for: 

Search

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/selenium-grid-tutorial.png","url":"https://www.guru99.com/images/selenium-grid-tutorial.png","width":"700","height":"250","caption":"Selenium Grid Tutorial","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/introduction-to-selenium-grid.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/selenium","name":"Selenium"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/introduction-to-selenium-grid.html","name":"Selenium Grid Tutorial: Setup a Hub and Node"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/introduction-to-selenium-grid.html#webpage","url":"https://www.guru99.com/introduction-to-selenium-grid.html","name":"Selenium Grid Tutorial: Setup a Hub and Node","dateModified":"2026-06-30T18:16:19+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/selenium-grid-tutorial.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/introduction-to-selenium-grid.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/admin","name":"Krishna Rungta","url":"https://www.guru99.com/author/admin","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/krishna-rungta-v2-120x120.png","url":"https://www.guru99.com/images/krishna-rungta-v2-120x120.png","caption":"Krishna Rungta","inLanguage":"en-US"},"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"Selenium","headline":"Selenium Grid Tutorial: Setup a Hub and Node","description":"Selenium Grid is a part of the Selenium Suite that specializes in running multiple tests across different browsers, operating systems, and machines in parallel.","keywords":"selenium","speakable":{"@type":"SpeakableSpecification","cssSelector":[".entry-title",".summary"]},"@type":"Article","author":{"@id":"https://www.guru99.com/author/admin","name":"Krishna Rungta"},"dateModified":"2026-06-30T18:16:19+05:30","image":{"@id":"https://www.guru99.com/images/selenium-grid-tutorial.png"},"copyrightYear":"2026","name":"Selenium Grid Tutorial: Setup a Hub and Node","subjectOf":[{"@type":"HowTo","name":"How to Set Up Selenium Grid?","description":"Here is a step-by-step process on how to Set up Selenium Grid.","step":[{"@type":"HowToStep","name":"Step 1) Download the Selenium Server","text":"Download the Selenium Server from https://www.selenium.dev/downloads/:","image":"https://www.guru99.com/images/selenium-grid-setup-1.png","url":"https://www.guru99.com/introduction-to-selenium-grid.html#step1"},{"@type":"HowToStep","name":"Step 2) Place Selenium Server .jar file","text":"You can place the Selenium Server .jar file anywhere in your HardDrive. But for the purpose of this tutorial, place it on the C drive of both Machine A and Machine B. After doing this, you are now done installing Selenium Grid. The following steps will launch the hub and the node.","url":"https://www.guru99.com/introduction-to-selenium-grid.html#step2"},{"@type":"HowToStep","name":"Step 3) Launch a hub.","text":"We are now going to launch a hub. Go to Machine A. Using the command prompt, navigate to the root of Machine A\u2019s \u2013 C drive, because that is the directory where we placed the Selenium Server.","image":"https://www.guru99.com/images/launch_hub.jpg","url":"https://www.guru99.com/introduction-to-selenium-grid.html#step3"},{"@type":"HowToStep","name":"Step 4) verify whether the hub is running is by using a browser","text":"Simply open up a browser and go to http://localhost:4444/grid/console","image":"https://www.guru99.com/images/view_hub_from_browser.jpg","url":"https://www.guru99.com/introduction-to-selenium-grid.html#step4"},{"@type":"HowToStep","name":"Step 5) Launch a node.","text":"Now that the hub is already set up, we are going to launch a node. Go to Machine B and launch a command prompt there.","image":"https://www.guru99.com/images/grid_2_launch_node.png","url":"https://www.guru99.com/introduction-to-selenium-grid.html#step5"},{"@type":"HowToStep","name":"Step 6) Check results.","text":"Go to the Selenium Grid web interface and refresh the page. You should see something like this. At this point, you have already configured a simple grid. You are now ready to run a test remotely on Machine B.","image":"https://www.guru99.com/images/view_node_from_browser.jpg","url":"https://www.guru99.com/introduction-to-selenium-grid.html#step6"}]},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is the difference between a hub and a node in Selenium Grid?","acceptedAnswer":{"@type":"Answer","text":"The hub is the single central machine where you load tests and manage the grid. Nodes are the machines that actually run the tests on specific browser and OS combinations. A grid has one hub and one or more nodes."}},{"@type":"Question","name":"What is the difference between Selenium Grid 1 and Grid 2?","acceptedAnswer":{"@type":"Answer","text":"Grid 1 uses a separate remote control and requires Apache Ant, supporting only Selenium RC scripts and one browser per control. Grid 2 is bundled with the Selenium Server jar, needs no Ant, and supports both RC and WebDriver scripts."}},{"@type":"Question","name":"How do you run a test on a specific browser using Selenium Grid?","acceptedAnswer":{"@type":"Answer","text":"Create a DesiredCapabilities object, set its browserName and platform, then pass it to a RemoteWebDriver pointed at the node's URL. The grid routes the test to a matching node for that browser and OS."}},{"@type":"Question","name":"How does AI improve Selenium Grid test execution?","acceptedAnswer":{"@type":"Answer","text":"AI can prioritize and parallelize test runs, predict flaky tests, balance load across nodes, and self-heal broken locators. This reduces execution time and maintenance effort on large grids running many browser-OS combinations."}},{"@type":"Question","name":"Can AI help configure and scale a Selenium Grid?","acceptedAnswer":{"@type":"Answer","text":"Yes. AI tools can recommend optimal node counts, generate JSON configurations, auto-scale cloud grids based on queue length, and detect underused capacity, helping teams run large suites efficiently without manual tuning."}}]}],"@id":"https://www.guru99.com/introduction-to-selenium-grid.html#schema-250128","isPartOf":{"@id":"https://www.guru99.com/introduction-to-selenium-grid.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/introduction-to-selenium-grid.html#webpage"}}]}
```
