As described In my EARLIER POST, Selenium grid 2 Is useful to execute webdriver software tests on multiple nodes In parallel. So we need to set up selenium grid 2 nodes for webdriver software test execution. But before that, Your selenium grid hub should be configured and in running mode as described in my PREVIOUS POST. Now lets configure selenium grid 2 single node to execute webdriver software automation tests in parallel in selenium grid.
Note : Here we are configuring selenium grid node on same machine where selenium grid hub is running for your easy understanding. Later on we will learn how to configure hub and nodes on different machines and run software automation test on it.
What Is Node
What Is Node
Node is the point which accept test requests from hub and execute them. We can configure node in such a way to execute tests in parallel on different browsers at the same time. Also we can set max number of browsers allowed to run test at a time, timeout etc. in upcoming posts.Registering Selenium Grid 2 Node To Hub
We need to register selenium grid node to hub so that hub can understand where to run software automation tests when receive request for test execution. But before that please read bellow given prerequisites.
- Selenium grid hub should be In running mode as described In previous post.
- "chromedriver.exe" file should be located in D: drive. It will be needed to run tests in google chrome browser. Read THIS POST to know from where to download it if you do not have "chromedriver.exe" file.
- "IEDriverServer.exe" file should be located in D: drive. It will be needed to run tests in Internet explorer browser.Read THIS POST to know from where to download it if you do not have "IEDriverServer.exe" file.
- Internet explorer browser's protected modes should be enabled for all zones as described in THIS POST and browser zoom level should be set to 100% as described in THIS POST.
Now follow the steps given bellow.
- Open another command prompt (Separate than hub command prompt).
- Navigate to D: drive by typing command D: in command prompt.
- Type bellow given command syntax in command prompt and press ENTER button.
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
- selenium-server-standalone-2.52.0.jar -> Selenium standalone server jar file. Modify It as per your jar file version in above command if it is not 2.52.0.
- 5566 -> port number which will be used by node.
- http://localhost:4444/grid/register : URL to register node where hub is running. Our current configuration is running hub and nodes on same machine so localhost in URL will work here.
- Note : If node Is running on different machine than the hub machine then you need to replace IP address of hub machine with "localhost" in above URL.
- -Dwebdriver.ie.driver="D:/IEDriverServer.exe" : Set path of IEDriverServer.exe file for node to run test in internet explorer browser.
- -Dwebdriver.chrome.driver="D:/chromedriver.exe" : Set path of chromedriver.exe file for node to run test in google chrome browser.
Note : Please restart hub and node if face any issue on any stage during test. To restart grid 2 node
- Press CTRL+c keys of keyboard to shutdown node.
- Run above command once again to register node with hub.
Verify whether grid node is running fine
Now If you access URL : http://localhost:4444/grid/console. It will show you page like bellow.
You can see, there are different browsers like 1 IE, 5 Firefox and 5 chrome browsers which you can use to run your software automation test. Now, Selenium grid is ready to use where hub and one node are running on same machine.
Now supposing we have 1 test case and wants to execute it in parallel in different 3 browsers. Can we do it using this configuration? Answer is Yes.. View my NEXT POST to know how to do it using selenium grid 2.