Execute Test on Multiple Nodes in Selenium Grid

Let’s see, How can you Execute Test on Multiple Nodes in Selenium Grid. In previous tutorials, You have seen, How can you execute the Test Case on multiple Browsers. Now let’s see, how can you execute the Test Case on multiple Nodes.

 

Objective – Execute the single Test on Multiple Nodes.

For this, you need to create multiple nodes. We will create the two nodes. On one node we will open the firefox and another node we will open the Chrome and execute the Test Case on both of the Nodes.

 

Please note the below-mentioned points for this scenario-

  1. Invoke the Selenium Hub. You can refer this tutorial Create Node and Hub in Selenium Grid
  2. Now invoke your first Node, Invoke node with Firefox. You can use below-mentioned command-
    java -jar selenium-server-standalone-2.53.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 5556 -browser browserName=firefox

 

  • Now invoke your second Node, Invoke second Node with Chrome. You can use below-mentioned command-
    java -Dwebdriver.chrome.driver=C:\chromedriver\chromedriver.exe -jar selenium-server-standalone-2.53.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 5566 -browser browserName=chrome

 

 

  • Now you can open your grid WebConsole to verify the Browsers and Node availability.

 

Now let’s see the class code or Test class code, what do you want to execute on multiple Nodes.

 

You can see, In the above code, You are getting the BrowserName from dataProvider and on the basis of the BrowserName, Browser is getting invoked.

 

We are passing two Browsers from DataProvider firefox and Chrome.

Now Question is, How can we Execute this on Multiple Nodes using Selenium Grid ?

To execute the Test Scripts, you don’t  need to put any extra effort. Till now you have started the hub and Two different Nodes with different browsers. Now you just need to execute the above Test  Script using testng.xml .

 

Selenium grid will start the execution on both nodes automatically. Here, you don’t need to do anything special for it.

If you have two Nodes with multiple browsers on each node and you execute the above script then Selenium will pick up the nodes randomly and execute the test on these nodes. In case you need to bound the execution then you need to invoke the specific browsers on specific nodes.

 

That’s all, How can you execute the single test on multiple nodes.

0 Comment

Leave a Reply