</>

Technology

Selenium

Difficulty

Beginner

Interview Question

What is a Node in Selenium Grid?

A Node is a machine attached to the Selenium Grid Hub that executes tests on a specific browser and OS configuration. Multiple nodes can be attached to one Hub.

Answer

Node in Selenium Grid

Node is a remote machine (physical or virtual) that is registered with the Hub and actually executes the browser tests.

Node characteristics:

  • Has one or more browsers installed (Chrome, Firefox, Edge, etc.)
  • Registers itself with the Hub so the Hub knows what capabilities it offers
  • Receives test commands from the Hub and executes them in the browser
  • Can run multiple browser instances simultaneously (configurable maxInstances)
  • There can be multiple nodes in a Selenium Grid

Registering a Node with the Hub:

Bash
# Selenium 3
java -jar selenium-server-standalone-3.141.59.jar \
  -role node \
  -hub http://localhost:4444/grid/register \
  -browser browserName=chrome,maxInstances=3 \
  -browser browserName=firefox,maxInstances=3

# Custom port for node
java -jar selenium-server-standalone-3.141.59.jar \
  -role node \
  -hub http://hub-machine:4444/grid/register \
  -port 5555

Selenium 4 Node:

Bash
java -jar selenium-server-4.x.x.jar node \
  --hub http://hub-server:4444 \
  --port 5555

Node configuration JSON (Selenium 3):

JSON
{
  "capabilities": [
    {
      "browserName": "chrome",
      "maxInstances": 3,
      "seleniumProtocol": "WebDriver"
    },
    {
      "browserName": "firefox",
      "maxInstances": 3,
      "seleniumProtocol": "WebDriver"
    }
  ],
  "maxSession": 6,
  "port": 5555,
  "host": "node-machine-ip",
  "hubHost": "hub-machine"
}

Multi-node setup:

CODE
[Hub: hub-server:4444]
  ├── [Node 1: win-machine:5555] — Chrome x3, Firefox x3
  ├── [Node 2: mac-machine:5556] — Safari x2, Chrome x2
  └── [Node 3: linux-machine:5557] — Firefox x4, Edge x2

Node vs Hub:

HubNode
RoleRoutes requestsExecutes tests
Has browserNoYes
Port44445555 (configurable)
Count1 per GridMany
PurposeCentral managerTest executor

Key definition: Node is the machine which is attached to the Hub. There can be multiple nodes in Selenium Grid. Each node has browsers installed and runs the actual test sessions.

Follow AutomateQA

Related Topics