Thursday, August 30, 2018

Running Multiple Nodes Of Selenium Grid On Same Motorcar To Operate Webdriver Test

| Thursday, August 30, 2018
Earlier nosotros learnt, How to showtime unmarried node on i machine every bit described inwards THIS POST. Now our side past times side enquiry is "can nosotros run multiple selenium grid nodes on same machine?". Answer is yes. Selenium grid allows us to run multiple nodes on same machine. In general, It is non required to run multiple nodes on same machine every bit nosotros tin lavatory command disclose of browsers every bit described inwards THIS POST in addition to disclose of browser sessions inwards THIS POST. So it is tardily to configure i node on i machine in addition to run bear witness on it every bit per requirements. But withal let's come across an example of running multiple nodes on same machine.

As yous know, Selenium grid node is using port to brain asking from hub in addition to ship reply back. Till now, We accept used 5566 port to run node inwards all previous examples of selenium grid. So if i node is already running on 5566 port in addition to yous wants to showtime 2d node on same machine in addition to thus yous bespeak to utilization other ship 5567 every bit nosotros tin lavatory run only i node per port number. Let's showtime i hub in addition to ii nodes on same machine in addition to run tests on both of them.

Start selenium grid hub
Start selenium grid hub every bit described inwards THIS POST.

Register selenium grid node 1
Open command prompt in addition to run bellow given command inwards it to showtime 1st node. It volition configure node 1 to run ii Firefox in addition to ii chrome browser instances but max ii instances at a time.
java -jar selenium-server-standalone-2.52.0.jar -role node -Dwebdriver.ie.driver="D:/IEDriverServer.exe" -Dwebdriver.chrome.driver="D:/chromedriver.exe" -hub http://localhost:4444/grid/register -port 5566 -browser browserName=firefox,maxInstances=2 -browser browserName=chrome,maxInstances=2 -maxSession 2

Register selenium grid node 2
Open but about other command prompt in addition to run bellow given command inwards it to showtime 2d node. It volition configure node ii to run ii Firefox in addition to ii chrome browser instances but max ii instances at a time.
java -jar selenium-server-standalone-2.52.0.jar -role node -Dwebdriver.ie.driver="D:/IEDriverServer.exe" -Dwebdriver.chrome.driver="D:/chromedriver.exe" -hub http://localhost:4444/grid/register -port 5567 -browser browserName=firefox,maxInstances=2 -browser browserName=chrome,maxInstances=2 -maxSession 2

Check both nodes running properly or not
Now if yous access URL : http://localhost:4444/grid/console , It volition demo yous both nodes running on dissimilar ports every bit shown inwards bellow given image. That agency your nodes are registered alongside hub in addition to get to use.


Create in addition to run tests on both nodes of grid
We tin lavatory utilization bear witness cases of "timeout" bear witness inwards this example.
  • Create bear witness cases(fillingForm.java in addition to Calc.java) in addition to testng.xml files every bit described inwards PREVIOUS POST.
  • un-comment driver.quit(); from both bear witness cases.
Now run tests from testng.xml file. It volition launch iv browsers instances(2 instances on each node) in addition to showtime executing tests on it.

If yous refresh grid console page during bear witness execution, it volition demo yous that ii sessions are running on node 1 in addition to ii sessions are running on node ii every bit shown inwards bellow image.


This way nosotros tin lavatory run multiple nodes on same machine to execute selenium webdriver tests.

Note : I don't know if this is wrong way but i know it is possible in addition to it runs your tests on both nodes. I tried it in addition to plant for me thus i accept shared this information alongside you. Let me know if anyone of yous facial expression upwardly whatsoever consequence inwards this combination.

Related Posts