What is Selenium Grid
Selenium Grid is a part of the tool in selenium, that specializes in running many
tests across different browsers, operating systems, and machines in parallel.
Selenium Grid types:
Selenium Grid has 2 types of versions first one is Grid 1 and the second one is Grid 2.
We will give preference only on Grid 2.Because Grid 1 is being overcome by the
Selenium Team.
Where ever you run the test on only a single machine called HUB.Selenium grid uses a
hub-concept.This execution will be done in different machines called nodes.
Use of Selenium Grid:
You should use Selenium Grid when you want to do either one or both of following:
1. Run your tests against different browsers, operating systems, and all machines at a time.
This will ensure that the application you are Testing is favorable with a wide range of
browser-O.S combinations.
2. Save time in the execution of your test suites. If you set up Selenium Grid to run, say, 3 tests
at a time, then you would be able to finish the all-suite around 3 times faster.
Difference between Selenium Grid 1.0 and Selenium Grid 2.0 :
Grid 1 Grid 2
Selenium Grid 1, has own remote control.That is differ Selenium Grid 2 is now bundled with the Selenium Server jar file
from the Selenium RC server. They are two different programs.
first, you can use Grid 1.Then you need to install and You do not need to install Apache Ant in Grid 2.
configure Apache Ant.
It Can only support Selenium RC commands/scripts. It Can support both Selenium RC and WebDriver scripts.
You can only automate one browser per remote control. You can browse One remote control can automate up to 5 browsers.
What are a Hub and Node?
The Hub:
The hub is the central point where you load your tests into.There is only one hub use in a grid.
The hub is released only on a single machine. Say, a computer whose O.S is Windows 7 and whose
browser is IE. The machine containing the hub is where the tests will run.
The Nodes:
Nodes are the Selenium instances that will execute the tests that you loaded on the hub.There can
be one or more nodes in a grid. Nodes can be launched on many machines with different platforms and browsers.
How to Install and Use Grid 2.0?
In Selenium Grid 2, you will use 2 machines. First machine along with the system that will run the hub. while the other the machine will run a node. The hub runs as "Machine A" while the machine, The node runs will be "Machine B". It also important to note IP addresses. Let us say the Machine A has based IP address. while Machine B has also based on IP address.
six steps are involved in installing the selenium grid 2:
Step1 :
Download the Selenium Server
Step2 :
you can place the Selenium Server .jar file anywhere in your HardDrive. But this tutorial, place it on the C drive of both
Machine A and B. After doing this, you are done installing Selenium Grid.
The following steps will launch the hub and the node.
Step 3
Now We are going to launch the hub. Go to Machine A. Using the command prompt, navigate to the root of Machine A & C drive.
Because that is the directory where we placed the Selenium Server.On the command prompt, type java -jar selenium-server-standalone-2.30.0.jar -role hub
The hub should launch.
Step 4
Another way to verify whether the hub is running is by using a browser. Selenium Grid, by default, uses Machine A's port 4444 for its web interface.
open up a browser and go to http://localhost:4444/grid/console
Step 5
Now that the hub is already set up, we are going to launch a node. Go to Machine B and launch a command prompt there.
Navigate to the root of Drive C and type the code below. We used the IP address because that is where the hub is running.
We also used port 5566 though you may choose any free port number you desire. Introduction to Selenium Grid When you press Enter, your command prompt
should be like the image below.
Step 6
Go to the Selenium Grid web interface and refresh the page. At this point, already configured a simple grid. You are now ready to run a test on Machine B.
Summary :
1. Selenium Grid used to run many tests on different browsers and platforms.
2. Grid uses the hub-node concept.
3.The hub is the central point wherein you load your tests.
4.To install Selenium Grid, you only need to download the Selenium Server jar file. The same file used in running Selenium RC tests.
5.There are 2 ways to verify if the hub is running: one was through the command prompt, and the other was through a browser.
6.To run the test scripts on the Grid, you should use the Desired Capabilities and the Remote Web Driver objects.
. DesiredCapabilites used to set the type of browser and OS that we will automate
. RemoteWebDriver use to set which node (or machine) that our test will run against.
