Earlier nosotros learnt, How to outset unmarried node on ane machine every bit described inwards THIS POST. Now our adjacent inquiry 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 command publish of browsers every bit described inwards THIS POST in addition to publish of browser sessions inwards THIS POST. So it is slow to configure ane node on ane machine in addition to run seek on it every bit per requirements. But even hence let's run across an example of running multiple nodes on same machine.
As yous know, Selenium grid node is using port to psyche asking from hub in addition to shipping answer back. Till now, We accept used 5566 port to run node inwards all previous examples of selenium grid. So if ane node is already running on 5566 port in addition to yous wants to outset 2d node on same machine in addition to hence yous ask to utilisation other post service 5567 every bit nosotros tin run only ane node per port number. Let's outset ane 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 outset 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 to a greater extent than or less other command prompt in addition to run bellow given command inwards it to outset 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 demonstrate yous both nodes running on dissimilar ports every bit shown inwards bellow given image. That agency your nodes are registered amongst hub in addition to ready to use.
Create in addition to run tests on both nodes of grid
We tin utilisation seek cases of "timeout" seek inwards this example.
- Create seek 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 seek cases.
Now run tests from testng.xml file. It volition launch iv browsers instances(2 instances on each node) in addition to outset executing tests on it.
If yous refresh grid console page during seek execution, it volition demonstrate 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 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 hence i accept shared this information amongst you. Let me know if anyone of yous appear upward whatever final result inwards this combination.