Selenium Grid in Shiksha
Author: Vinay Gupta
What is Selenium Grid
Selenium Grid is a part of the Selenium Suite which uses Remote Web driver to run multiple test cases on different operating systems, browsers and machines simultaneously.

Architecture of Selenium Grid
Selenium Grid has a client-server architecture in which client is known as nodes and Server is known as hub.

Hub
· Hub is a central unit which controls all the nodes
· Only one hub has to be initialized for Grid
Nodes
· Nodes are the clients for Selenium Grid
· Every node needs to be assigned to a hub
· Browsers and respective browser-drivers must be installed on node Machine
· Multiple nodes can be initialized on a single Machine
How to achieve Selenium Grid
Step 1: Download Selenium Server and browser drivers on All Machines
· Go To https://selenium.dev/downloads/ and download the latest version of Selenium Server jar file.
· Download browser (chromedriver or gecodriver version as per browser requirement).
· Put them in a single folder.
Step 2: Hub Setup
· Open terminal/cmd and change directory to folder containing selenium-Server jar file.
· Run command as
>> java -jar <Selenium Jar file> -role hub.
e.g. java -jar selenium-server-standalone-3.141.59.jar -role hub

· In current example, hub is setup on http://192.168.240.115:4444
· Open link to verify http://192.168.240.115:4444/grid/console (This is an intranet link.)

Step 3: Nodes Setup
· Open terminal/cmd and change directory to folder containing Selenium-Server jar file.
· Run command as:
>> java -Dwebdriver.chrome.driver=<browser driver> -jar <Selenium Server Jar> -maxSession 10 -role webdriver -hub http://<IP_of_Hub>:<Port_of_hub>/grid/register -port <port number for node>
e.g. java -Dwebdriver.chrome.driver=chromedriver.exe -jar Selenium.jar -maxSession 15 -role webdriver -hub http://192.168.114.38:4444/grid/register -port 8365

· Open http://192.168.240.115:4444/grid/console to verify where IP and port is of the hub.

Step 4: Code snippet to open Browser using Grid (Language JAVA).

Outcome from Selenium Grid in Shiksha
1. Distributed network for Automation suite.
Scripts can be executed on multiple machine for single execution.
2. Thread Count can be increased many folds.
The Maximum number of script execution simultaneously has increased from 10 to 30.
3. Reduction of total Execution Time
Total execution time has decreased from 13 hrs. to 2.5 hrs.
Limitations faced during setup in Shiksha
· Machine in which you have to setup Selenium Hub must have static IP because we need to use that IP in automation Scripts.
· Thread count got limited due to the load increased on the Test Environment (Limitations of Test environment architecture).
· While providing chrome driver capabilities, we need to use default setting of all other nodes.
· A Selenium node by default uses 5 browser instances, if we need to increase browser instance we need to setup a new node on the system.