In this Post I will tell you how to set-up Selenium Grid on your system.
Check
that Java is installed in your system by using the command “java
-version”. If Java is installed it will give the output about Java
Version that is installed in your system. Else download the Java from
Java website (http://www.java.com/en/download/index.jsp).
Check
ANT is installed in your system by using the command “ant -version”.If
Ant is installed it will give the output about Ant Version that is
installed in your system. Else download the Apache Ant from Apache
website (http://ant.apache.org/).
-
Go
to the Unpacked directory of the Selenium grid using command prompt
and type the command “ant launch-hub”. This will launch the Selenium
Grid Hub on a default port “4444” to check whether the selenium grid is
running. Type the URL “http://localhost:4444/console ” on your browser and check that you are able to see the selenium hub console on the browser.
Now
go to the same Selenium Grid directory using command prompt and type
the command “ant launch-remote-control”. This will start the Selenium
Grid Remote control on default port “5555” and environment “*firefox”
and register it to the Hub which you had earlier started.
Now
after starting the selenium remote control we will test the example
provided with Selenium Grid for sequence testing in single machine. For
this go to the Selnium grid folder from command prompt and type the
command “ant run-in-demo-sequence”. This will execute the test example
provided with selenium grid to be executed in sequence.
Now you may had noticed in the setting up
steps that I am running the test in sequence. You may think in your mind
that, what's special in that? The same things can be achieved when we
use a Selenium RC.Then here comes the important part of Selenium Grid.
Setting up Parallel execution on a single machine
Start the hub and one remote control in the same way as in the earlier setting up steps.
Now go to the Selenium Grid folder using command prompt and type the command
“ant -Dport =5556 launch-remote-control”
This
will start another remote control on port “5556” and register it to the
local hub. If you want to register more remote control to the Hub. You
can do that by starting multiple remote control but with different
ports.
-
4. Now
to run the test in parallel. Go to the selenium grid directory using
command prompt and type the command “ant run-demo-in-parallel”. This
will run the example tests given with selenium grid in parallel
Setting up parallel execution for different machines and different environments
In this case start the Hub normally as you do in any of the system.
For starting the remote control use the following command.
ant -Dport=<port> -Dhost=<hostname> -DhubURL=<hub> -Denvironment=<environment> launch-remote-control
Here
“-Dport” should be used to set the port of the remote control.
“-Dhost” should be used to set the host(where the remote control has
been started) IP. This is the IP which the hub will use to talk to the
remote control.
“-DhubURL” should be used to set the Hub Url where the current remote control will register itself.
“-Denvironment” should be used to set an environment name that remote control represents to the hub.
Now start 4 different remote controls from 2 different machines and register them to the hub.
After
this check the Hub console. It will look similar to the table as shown
below depending upon the remote control that are registered to the Hub.
Then
to verify your set-up go to the Selenium Grid folder from the command
prompt and type the command “ant run-demo-in-parallel”
This will run an example test accompanied with the Selenium Grid to run in parallel.
Advantages of Selenium Grid
Remote
Execution of the selenium tests can be done using Selenium Grid
without actually copying your test code to to remote system.
Selenium Grid can be used to save time by executing independent testcases in parallel.
Load
Testing can be done if we register a lot of remote control to a single
hub and execute testcase in parallel to simulate multiple transactions
at a single time period.