Selenium Grid Tutorial: Playing with node registration parameters in grid

As we have seen in previous post Selenium Grid Tutorial : Setting up hub and nodesWe have seen how to setup hub and nodes. But in this post we are going to see various parameters that is used in node setup to take optimum benefit of resources as per our need and availability.




So lets see all the parameters and their use one after another..

-port : In general understand it as an address for specific process and this helps to understand which process is being listened at which port.

By default node registered on port 5555 if port parameters is not defined in registering a node with hub.
So lets see how to provided any port number as per our need But before running this command reach to the folder/location where you have kept your selenium standalone jar in your computer and here node is being executed on the same machine just by opening another terminal so here we have taken http://localhost:4444

java -jar selenium-server-standalone-2.48.2.jar -role webdriver -hub http://localhost:4444/grid/register -port 5557

In above example, -port is being followed by 5557 and by doing so we have assigned port 5557 to this node.




This can be seen whether node has beed registered with hub with port 5557 or not just by opening console on following URL http://localhost:4444/grid/console (Note: by default hub takes 4444 as port)
If node would have been registered then it will be visible on grid console like this

Selenium Grid Console with port parameter

Here you can see 5 instance of Firefox, 5 Instance of Chrome and 1 Instance of IE browser by default if we have not provided any custom parameter.

But if we want to see more configuration detail about the registered node then click on Configuration  tab.
So here is the screenshot of Configuration tab
Selenium Grid console with Configuration detail-browser :  This parameter is used to do the custom session of various browser. Suppose we want only firefox or chrome or ie browser then this parameter can be used like this 

java -jar selenium-server-standalone-2.48.2.jar -role webdriver -hub http://<IP of hub maachine>:4444/grid/register -port 5557 -browser browserName=firefox

But above command would register only one instance of Firefox  like this
-browser parameterSo in the same fashion if we want to use only chrome then above command would be like this

java -jar selenium-server-standalone-2.48.2.jar -role webdriver -hub http://<IP of hub maachine>:4444/grid/register -port 5557 -browser browserName=chrome

and for IE browser place iexplore in place of chrome/firefox in above command

maxInstances: it tells how many number of browser instance could be used from registered node. 

So in above command that we have seen for -browser parameter, if we want to increase the number of instance more than default 1 to 5 then we need to use one more parameter maxInstances followed by browser name. Like this

java -jar selenium-server-standalone-2.48.2.jar -role webdriver -hub http://<IP of hub maachine>:4444/grid/register -port 5557 -browser browserName=firefox,maxInstances=3

Above command would register three instance of Firefox browser from node to Hub and it would look like this

Selenium Grid with 3 instance of Firefox

Note: In this example node is on separate machine that is why IP is different from previous snapshot

maxSession: This parameter tell us how many number of remote session can be establish simultaneously.

java -jar selenium-server-standalone-2.48.2.jar -role webdriver -hub http://<IP of hub maachine>:4444/grid/register -port 5557 -browser browserName=firefox,maxInstances=3

version  and platform:  we can also give these two parameter as well but in most of the cases grid make decision which platform and version of browser is present on node. So if you want to mention it explicitly at the registration of node then its good but if you don’t then this is not going to make any difference. so lets see one example of these two parameter as well

java -jar selenium-server-standalone-2.48.2.jar -role webdriver -hub http://<IP of hub maachine>:4444/grid/register -port 5557 -browser browserName=firefox,maxInstances=3,version=40.0,platform=LINUX

in above example we are registering a firefox browser of version 40.0 from Linux machine.




Setting path of third party binaries in Selenium grid(mainly for Chrome,IE )
But before that lets see one exception on node which have already registered Chrome browser with Hub.
exception seems like this

org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html

So here is the solution to execute your remote-webdriver test on one node with Chrome browser.

java -Dwebdriver.chrome.driver=/path/to/chromedriver  -jar selenium-server-standalone-2.48.2.jar -role webdriver -hub http://<IP of hub maachine>:4444/grid/register -port 5557 -browser browserName=chrome

so above command will help you out to resolve your chrome related issue.

So lets see some more commands with various combination of browser with various instances and sessions

Command 1:  For one IE, 1 Chrome and 1Firefox instances from some node so it would look like this

java -jar selenium-server-standalone-2.48.2.jar -role webdriver -hub http://localhost:4444/grid/register -port 5557 -browser browserName=chrome -browser browserName=firefox -browser browserName=iexplore

 Command 2: For 2 instance of IE , 10 instances of Firefox and 7 instance of Chrome(please forgive me since i am going to run this on mac or linux machines since i don’t have my windows machine with me right now)
But always remember we are not talking about default browser session so rememebr it will be five and not more than that we can run at a time on any node without any customisation.

java Dwebdriver.chrome.driver=/path/to/chromedriver -jar selenium-server-standalone-2.48.2.jar -role webdriver -hub http://localhost:4444/grid/register -port 5557 -browser browserName=chrome,maxInstances=7 -browser browserName=firefox,maxInstances=10 -browser browserName=iexplore,maxInstances=2

Note: give path of chromedriver without any single or double quote in above command like this
For Chrome
-Dwebdriver.chrome.driver= E:/chromedriver.exe

For IE
-Dwebdriver.ie.driver=E:/<ie driver exe>

Command 3: Use command 2 with custom session that should be sum of (10+7+2)

java -jar selenium-server-standalone-2.48.2.jar -role webdriver -hub http://localhost:4444/grid/register -port 5557 -browser browserName=chrome,maxInstances=7 -browser browserName=firefox,maxInstances=10 -browser browserName=iexplore,maxInstances=2 -maxSession 17

Note: add third-party executable in above if you are not using Unix core machines(because in that case, you have already kept this binary in lib folder so in that case you don’t need. To read more about setting the path in mac or other Unix kernel machine read following post  Installing ChromeDriver on Mac.

Dwarika Dhish Mishra

My name is Dwarika Dhish Mishra, its just my name and I am trying to bring the worth of my name in to actions and wants to be the solution not the problem. I believe in spreading knowledge and happiness. More over I am fun loving person and like travelling a lot. By nature I am a tester and a solution maker. I believe in the tag line of http://ted.org “Idea worth spreading” . For the same, I have created this blog to bring more and more learning to tester fraternity through day to day learning in professional and personal life. All contents are the part of my learning and so are available for all..So please spread the contents as much as you can at your end so that it could reach to every needful people in testing fraternity. I am pretty happy that more and more people are showing interest to become the part your Abode QA blog and I think this is good sign for us all because more and more content would be before you to read and to cherish. You may write or call me at my Email id: dwarika1987@gmail.com Cell: 9999978609

You may also like...

4 Responses

  1. vedant says:

    can any one help me to run a test script in two system in windows 8.1 using selinium grid,with details about command prompt instructions in a step wise manner.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.