MaxSessions vs MaxInstances in Selenium Grid

In this tutorial, you will see MaxSessions vs MaxInstances in Selenium Grid. In previous tutorials, You have seen, how can you create the Node and open manage the browsers over the node.

Now you will see, How many browser instances you can create the single node and use these.

 

Now question is, How can you define a number of an instance you can create on a Node?

To define the instance for the particular Browser over the node. You need to append the MaxInstances in the command.

 

Like, We want to create 3 instances of firefox on our node then put the comma after the browser name and append the command with maxInstances=3 and it will create 3 instances of firefox on the node. Like –

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

 

Now, suppose you want to create 3 instances of firefox, 4 instances of chrome and 5 instances of IE. So command will look like –

java -jar selenium-server-standalone-2.53.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 5556 -browser browserName=firefox,maxInstances=3 -browser browserName=chrome,maxInstances=4 -browser browserName=iexplore,maxInstances=5

 

You can verify this on your Grid Web Console. To open the web console open http://localhost:4444/grid/console in your web Browser. After fire, the above command your console will look like –

Manage Instance on Node

 

Manage Session on Node in Selenium Grid

You have seen, How to create the Node, how to create the Browser instance on the Node. Now you will, how can you define the number of sessions on any Node.

To define the session on the node, You need to append the command -maxSession number_of_session in the create node command.

 

Like in the last command you created 3 instances of firefox, 4 of chrome and 5 of IE. Now you to fix the session for node due to processor capacity.

So now you have 12 total instances but your processor capacity is allowed to open 5 instances at a time. For this, you need to define sessions for your node. For this command will look like-

java -jar selenium-server-standalone-2.53.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 5556 -browser browserName=firefox,maxInstances=3 -browser browserName=chrome,maxInstances=4 -browser browserName=iexplore,maxInstances=5 -maxSession 5

 

Now we have defined 5 sessions. It means it doesn’t matter how many instance are available, At a time selenium will invoke only 5 instances.

 

Can we Open Multiple Nodes on the single machine ?

Yes, We can create multiple Nodes in one machine. To create another node, All you need to do is open the another command prompt. Go the-the directory where your selenium server is present and fire the start node command with the different port number.

 

After this another Node will be created, you can verify this using Grid Console web.

 

0 Comment

Leave a Reply