There might an instance in which we would want to run, for example, 50 tests in parallel.
50 browsers would consume the CPU power very fast, so we need to split the load between multiple machines.
Fortunately with Selenium Grid 2 this is not a problem.


On “Machine A” we need to start the Grid hub with the following command:

java -jar selenium-server-standalone-2.35.0.jar -role hub -port 5555

To “Machine A” we can give the number of the maximum Sessions, to control how many browser may run in parallel.
The following command starts a node on “Machine A”, plus gives the number of Sessions:

java -jar selenium-server-standalone-2.35.0.jar -role node -hub http://localhost:5555/grid/register -browser browserName=chrome,maxInstances=25 -maxSession 25

On the remote machines we also need to set up the selenium grid. For this we need the selenium-server-standalone-2.35.0.jar file, need to set up the java environment and add the browser drivers (chromedriver, iedriver) to the environment variables.
Then on “Machine B” we can register the remote machine to the hub with the following command:
java -jar selenium-server-standalone-2.35.0.jar -role node -hub http://TheHubIP:5555/grid/register -browser browserName=chrome,maxInstances=25 -maxSession 25

Of course you need to add the hub IP to the “TheHubIP” part.

Posted By István Lackó

    6 Responses to “How to connect multiple machines to the Selenium Grid hub”

  1. Aditya says:

    Just curious to know, what is the difference between maxinstances and maxsessions arguements while running node.

    • Hi,
      The answer is the following:
      MaxInstances – how many instances of same version of browser can run over the Remote System. So I can run X instances of Firefox and as well as Y instances of IE at the same time in remote machine. So total user can run X+Y instances of different browsers in parallel.
      MaxSession – how many browsers (Any Browser and any version) can run in parallel at a time in the remote system. So this overrides the Max Instances settings and can restrict the number of browser instances that can run in parallel.

  2. Asiq Ahamed says:

    VisGrid-UI for Selenium Grid

    VisGrid is a GUI for Selenium Grid. You can start hub, create and attach a Selenium node very easily and quickly.

    Download: http://www.codoid.com/products/view/2/30

  3. Silas Ray says:

    It should be noted that it’s often advisable not to run a node on the same machine as the hub, as is done here. While the hub doesn’t consume much in the way of CPU and memory resources, both the hub and the test client (the code actually executing the tests remotely through Selenium) consume lots of network resources, which can start to bog the system down, especially if your test code is interacting a lot with Selenium. The hub acts as a proxy to the remotes, so running the hub and node on the same machine essentially doubles network traffic on the loopback interface vs running the same number of instances purely locally.

  4. Ishwaryaa says:

    Thanks for the article,
    Could you please help me here – I am running my GridServer and Nodes on the cloud. Shall I make a p2p connection between grids.

Leave a Reply




XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>