Overview of Selenium Grid:-
The Selenium grid allows you to test between browsers by triggering test cases on different machines for each browser. Run a distributed test. You need to configure the hub and node so that all nodes listen to the hub and run the tests. Control of test triggers is on the local machine and is done by calling a browser on the remote computer / machine.
Hub:- A hub is a local machine that creates and triggers all test cases.
node:- The browser is called on a remote machine called a node.
Benefits of using a grid:-
We know that selenium allows web automation in multiple browsers, but only one Internet Explorer, Chrome, or Firefox browser can be downloaded to your local machine. If you want to run hundreds of test cases in different browsers, the selenium grid can help. If you have hundreds of test cases in real time, it will take forever to trigger them one by one. Selenium Grid saves time and runs multiple tests in parallel on multiple browsers on different nodes configured on a single hub (local machine).

Step-by-step guide to running tests using Selenium grid:-
Step 1:-Download the Selenium standalone server and Java development kit .Jar files to both the hub and the node machine.
(I) Download the standalone server jar file from (https://ift.tt/31HTh4V) to both the hub machine and the node machine.

(II) Download the Java Development Kit (JDK) on both the hub machine and the node machine, and set the path in the environment variable.
(A) Java (JDK) at https://ift.tt/3cLtuwb

Step 2:-Set the JDK path in both hub and node machine system variables.
(I) To set environment variables, go to the advanced system settings for the local machine (hub) and nod machine.

(II) Click “New” to start adding the JAVA_HOME path

(III) Go to the program file and go to[Java]Click to open the saved (jdk1.8.0_241) folder and copy the address.



(IV) Paste it into an environment variable named JAVA_HOME.

(V) Click the system variable path and add the Javabin path.

(VI) To get the Java bin path again, go to the JDK folder where you saved it and click the bin folder.

(VII) Copy the address to the bin folder

(VIII) Select the path and click the new button to paste it into the new path of the system variable.


Step 3:-Download the Chrome and Gecko drivers for Chrome and Firefox browsers respectively. (Download the Chrome and gecko driver .exe files to the node machine where the Selenium server jar is stored.)
(I) Chrome driver (chromedriver_win32.zip) from: -https: //chromedriver.storage.googleapis.com/index.html? Path = 81.0.4044.69 /

(II) Gecko driver for Firefox browser (geckodriver-v0.26.0-win64.zip):-https: //github.com/mozilla/geckodriver/releases

Step 4:-Open a command prompt and call the Jar file.
(I) Paste this into the command prompt and press Enter:-
java -jarselenium-server-standalone-3.141.59.jar-role hub

Step 5:-Open a browser and paste the grid IP address:-
10.0.0.159: 4444 / grid / console or localhost: 4444 / grid / console

Step 6:-Log in to another machine and register as a node machine.
(I) Open a command prompt and call the Jar file (same method as above)
(II) To call the Chrome browser on a node machine, paste the following command into the node command and press Enter.
java -Dwebdriver.chrome.driver = ”C: chromedriver.exe” -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub https://ift.tt/2UFCIlS -port 5566


Step 7:-After registering the node with another machine, refresh the browser on the hub machine where you entered the grid IP address.

Step 8:-Import the Selenium standalone server jar into your Eclipse project.
To import the Selenium standalone server Jar, click on the Java project[プロパティ]Go to and select the Java build path,[外部Jarの追加]Click.

Now you are ready to create a test case with the required functionality on your hub machine (Eclipse IDE).
code:-
Import java.net.MalformedURLException.
Import java.net.URL.
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
Public class remotetest {
public static void main (String[] args) throws MalformedURLException {
// TODO auto-generated method stub
// Automation-chrome, firefox, safari
DesiredCapabilities dc = new DesiredCapabilities ();
dc.setBrowserName (“chrome”);
dc.setPlatform (Platform.WINDOWS);
// Webdriver driver = new ChromeDriver ();
WebDriver Driver = New RemoteWebDriver (new URL (“http: // localhost: 4444 / wd / hub & # 8221;), dc);
driver.get (“http: //google.com”);
}
}
