Configure Hub and nodes in Selenium Grid

In the previous post, we have see what is Selenium Grid?  In this post, let’s see how to Configure Hub and nodes in Selenium Grid.

Download  Selenium Server jar:

Download Selenium Server jar file from Selenium official  site http://www.seleniumhq.org/download/Download the latest version and store it at any desired path in your system.

Selenium RC standalone

 

Configuring Hub:

Step#1 Open command prompt and navigate to the system location where you have stored Selenium Server jar file.

For navigating in command prompt use cd command.
cd C:\MyFolder

Command window

 

 

Step#2 Once you have navigated to the correct path, start the Hub by using the following command.

java -jar selenium-server-standalone-2.45.0.jar -role hub

After you run the above command , hub will start. If you will see the below message , that means hub has started successfully.

hub started in selenium

Note: Hub runs at a default port 4444.

Another way you can check the status in the browser by using the command http://localhost:4444/grid/console.

Grid Console

 

Configuring nodes:

Step#1 Now, Hub is up and running properly. For starting a node, open a new command window and navigate again to the system location where you have Selenium server jar file. Then type the below command to start a node.

java -jar selenium-server-standalone-2.45.0.jar -role node -hub http://localhost:4444/grid/register

Node Start in Selenium Grid

Step#2 To check the node status , go back to http://localhost:4444/grid/console in the browser. You will see no. of browsers for Selenium RC and Selenium Webdriver.

You will see 5 chrome, 5 Firefox and 1 Internet explorer.

Selenium Grid Node

These are the browser instances which will be used to execute the test cases in parallel.


 

If you want to have specific browsers as per your requirement, you can specify it while starting the node. Another important point is that you can choose the port number for the node.

Suppose, we want to start 3 Firefox browser and 1 internet explorer instances at the port 5556. Then open a new command window and run the below command.

java -jar selenium-server-standalone-2.45.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 5556 -browser browserName=firefox,maxInstances=3 -browser browserName=iexplorer,maxInstances=1

Here , we are specifying firefox and IE with -browser browsername and it will open the particular no. of browser as defined in keyword ‘maxinstance‘.

Refresh the web interface http://localhost:4444/grid/console.

Start node in selenium Grid

 

Registering chrome instance at a node: For starting Chrome browser, open a command window and run the below command. We are opening chrome instances.

java -Dwebdriver.chrome.driver=C:\Personal\Tools\chromedriver.exe -jar selenium-server-standalone-2.45.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 5557 -browser browserName=chrome,maxInstances=2

In the above command we are setting the chrome path to “Dwebdriver.chrome.driver“.

Chrome instance in Selenium grid

 


Important point to note is that while setting up the node , you can decide how many browsers you want to open for execution at a time. This parameter can be set by using the keyword maxsession.

For example: We are defining that only 2 browser session should open at time.

java -Dwebdriver.chrome.driver=C:\Personal\Tools\chromedriver.exe -jar selenium-server-standalone-2.45.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 5557 -browser browserName=chrome,maxInstances=4 -maxSession 1

 

In the next post , we will see how to use Json file to start a node.

Ask Question
Have any question or suggestion for us?Please feel free to post in Q&A Forum
Avatar photo

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...