How to set up Selenium Grid envirnoment

 Selenium Grid Configuration

Launch Hub
java -jar selenium-server-standalone-3.141.59.jar -role hub

Register Node
java -jar selenium-server-standalone-3.141.59.jar -role webdriver 
-hub http://192.168.0.114:4444/grid/register -port 5556

Register Node with specific browser
java -jar selenium-server-standalone-3.141.59.jar -role webdriver 
-hub http://192.168.0.114:4444/grid/register -port 5556 -browser browserName=firefox

Register Node with multiple browsers
java -jar selenium-server-standalone-3.141.59.jar -role webdriver 
-hub http://192.168.0.114:4444/grid/register -port 5556 -browser browserName=firefox  -browser browserName=chrome

Register Node with multiple browser and IE
java -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://192.168.0.114:4444/grid/register 
-port 5556 -browser browserName=iexplore  -browser browserName=chrome

Register Node with multiple instance of same browser
java -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://192.168.0.114:4444/grid/register 
-port 5556 -browser browserName=iexplore  -browser browserName=chrome  -browser browserName=firefox 
-browser browserName=firefox

Register Node with multiple instances of same browser
java -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://192.168.0.114:4444/grid/register 
-port 5556 -browser browserName=firefox,maxInstances=4

Register Node with multiple instances of different browsers 
java -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://192.168.0.114:4444/grid/register 
-port 5556 -browser browserName=firefox,maxInstances=4 -browser browserName=chrome,maxInstances=3 
-browser browserName=iexplore,maxInstances=2

To set session
java -jar selenium-server-standalone-3.141.59.jar -role hub -maxSession 10

We can start two node in same machine 
Run two times cmd and register nodes
cmd1
java -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://192.168.0.114:4444/grid/register 
-port 5556 -browser browserName=firefox,maxInstances=4 -browser browserName=chrome,maxInstances=3 
-browser browserName=iexplore,maxInstances=2
cmd2  Just change Port Name
java -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://192.168.0.114:4444/grid/register 
-port 5557 -browser browserName=firefox,maxInstances=2 -browser browserName=chrome,maxInstances=6 
-browser browserName=iexplore,maxInstances=8

Selenium Node : Configure drivers

Chrome
java -Dwebdriver.chrome.driver=C:\Webdrivers\chromedriver.exe -jar selenium-server-standalone-3.141.59.jar 
-role webdriver -hub http://192.168.0.114:4444/grid/register -port 5556 -browser browserName=chrome

Chrome+ie
java -Dwebdriver.chrome.driver=C:\Webdrivers\chromedriver.exe -Dwebdriver.ie.driver=C:\Webdrivers\IEDriverServer.exe 
-jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://192.168.0.114:4444/grid/register 
-port 5556 -browser browserName=chrome -browser browserName=iexplore

Chrome+ie+Edge
java -Dwebdriver.chrome.driver=C:\Webdrivers\chromedriver.exe 
-Dwebdriver.ie.driver=C:\Webdrivers\IEDriverServer.exe 
-Dwebdriver.edge.driver=C:\Webdrivers\MicrosoftWebDriver.exe -jar selenium-server-standalone-3.141.59.jar 
-role webdriver -hub http://192.168.0.114:4444/grid/register -port 5556 -browser browserName=chrome 
-browser browserName=iexplore -browser browserName=edge

Chrome+ie+Edge+Firefox
java -Dwebdriver.chrome.driver=C:\Webdrivers\chromedriver.exe 
-Dwebdriver.ie.driver=C:\Webdrivers\IEDriverServer.exe 
-Dwebdriver.edge.driver=C:\Webdrivers\MicrosoftWebDriver.exe -Dwebdriver.firefox.driver=C:\Webdrivers\geckodriver.exe 
-jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://192.168.0.114:4444/grid/register 
-port 5556 -browser browserName=chrome -browser browserName=iexplore -browser browserName=edge -browser browserName=firefox


How to create Maven Project
Install Maven
1)Download Maven  "http://maven.apache.org/download.cgi"
"apache-maven-3.6.0-bin.zip" file and extract it
2)Keep Extracted folder in C drive
3)Set Envirnoment varibles MAVEN_HOME  with directory path  ex "C:\apache-maven-3.3.9"and Path variable ex "%M2_HOME%\bin"
4)Checl Maven installed properly or not 
cmd->mvn -version

Create Project in Eclipse
1)File->New->Other->Maven-)click on maven project->next->next->provide group id 
ex "DemoProject" and artifact id ex "demo" then click on finish
2)Maven project will be created
3)Add all dependancies into POM.xml file 
To check "https://mvnrepository.com/artifact/org.testng/testng/6.14.3" and search dependency 
ex. selenium java and copy paste maven code into pom.xml file
ex. 

    org.testng
    testng
    6.14.3
    test



Use of Maven :- No need to main jar files