What is
Selenium Grid?
Selenium Grid is a part of the Selenium Suite
that specializes on running multiple tests across different browsers, operating
systems, and machines in parallel.
Selenium Grid uses a hub-node concept where
you only run the test on a single machine called a hub, but the execution will
be done by different machines called nodes.
What is a
Hub and Node?
Hub:
The
hub is the central point where you load your tests into.
There should only be one hub in a grid.
The hub is launched only on a single machine,
say, a computer whose OS is Windows 7 and whose browser is IE.
The machine containing the hub is where the
tests will be run, but you will see the browser being automated on the node.
Node:
Node is a Selenium instance 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 multiple machines
with different platforms and browsers.
The machines running the nodes need not be
the same platform as that of the hub.
How to setup
Grid 2.0?
In this section, you will use 2 machines. The
first machine will be the system that will run the hub, while the other machine
will run a node. For simplicity, let us call the machine where the hub runs as
"Machine A" while the machine where the node runs will be
"Machine B". It is also important to note their IP addresses. Let us
say that Machine A has an IP address of 192.168.1.1 while Machine B has an IP
of 192.168.1.2
Step 1
Download the Selenium Server by here and add Selenium Server .jar file to environment variable path
on both Machine A and Machine B.
Step 2
Go to Machine A and Launch a hub using the command prompt
C:\> java -jar selenium-server-standalone-2.42.2.jar -role hub
Step 3
The hub should successfully be launched. 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. Simply open up a browser and go to http://localhost:4444/grid/console
Also, you can check if Machine B can access the hub's web
interface by launching a browser there and going to http://ipMachineA:4444/grid/console where "ipMachineA" should be the IP address or
the hostname of the machine where the hub is running. Since Machine A's IP
address is 192.168.1.1, then on the browser on Machine B you should type http://192.168.1.1:4444/grid/console
Step 4
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.
Go to Machine B and launch a command prompt there.
C:\> java
-jar selenium-server-standalone-2.42.2.jar -role webdriver hub http://192.168.1.1:4444/grid/console
-port 5566
Where 192.168.1.1 is a IP address of Hub(Machine A).
Step 5
Go to the Selenium Grid web interface and refresh the page. You
should see something like this.
At this point, you have already configured a simple grid. You
are now ready to run a test remotely on Machine B.
0 Comments