Print

Running Tests on Selenium Grid 2.0 with Web Driver

In this section, you will use one computer as a hub and as a node to run a test with Web Driver on Selenium Grid 2.0.

 

Step 1: launch the hub with the command line below. 

C:\Selenium Server>java -jar selenium-server-standalone-2.39.0.jar -role hub

Step 2: launch the node with the command line below. 

Print

How to start a Selenium Grid Node

To start a node using default parameters, run the following command from a command line shell or console. Let's assume that we have downloaded version 2.39.0.

 

java -jar selenium-server-standalone-2.39.0.jar -role node -hub http://localhost:4444/grid/register

This assumes that Selenium Grid hub has been started on the local computer with the port 4444. The default port of the hub uses to listen for new request is port 4444. This is why port 4444 was used in the URL for locating the hub.

If you get any connection error, be sure to turn off the firewalls on the machines running your hub and nodes.

Print

How to start Selenium Grid Hub

When using Selenium Grid, generally, you should start a hub first because nodes are dependent on that. To start a hub with default parameters, run the following command from a command-line shell or console. This will work on all the supported platforms, windows linux, or MacOS. Let's say we have downloaded version 2.39.0 verion:

 

java -jar selenium-server-standalone-2.39.0.jar -role hub


This starts a hub using default parameter values.

Print

How to install Selenium Grid

Installation of Selenium Grid is very simple. Download the Selenium-Server jar file from the SeleniumHq website's download page. Navigate to the download page and see the download link in the Selenium Server section.

 

You can install it in a folder of your choice. Generally, you can use Java -jar selenium-server-standalone.<version number>.jar  command to run it. You will need to be sure that java executable is on your system execution path, so that you can run it from the command-line console.

Print

Comparison of Selenium Grid 1.0 and Selenium Grid 2.0

Selenium Grid has two versions. Selenium Grid 1.0 and Selenium Grid 2.0. Here are the main differences between them.

 

Selenium Grid 1.0

Selenium Grid 2.0

Selenium Grid 1.0 has its own remote control system, which is different from the current Selenium RC. Selenium Grid 2.0 is now bundled with the Selenium Server Jar file
Selenium Grid 1.0 can only support Selenium RC commands and scripts. Selenium Grid 2.0 supports both Selenium RC and WebDriver scripts.
Selenium Grid 1.0 can only automate one browser per remote control. Selenium Grid 2.0 one remote control can automate up to 5 browsers.
Selenium Grid 1.0 requires Apache Ant installation and configuration. Selenium Grid 2.0 does not require Apache Ant.
Print

When to Use Selenium Grid

Selenium Grid provides the functionality of running Selenium tests in parallel with different or the same browsers. You should use Selenium Grid in either one or both of following situations: 

 

  • Run your tests against different browsers, operating systems, and machines all at the same time. This will verify that the application under test is fully compatible with a wide range of browser-OS combinations.
  • Save time in execution of your test suites. For example, if you setup Selenium Grid to run 5 tests at a time, this means that you are able to finish the whole suite around 5 times faster.
Print

Different methods run in parallel on the same servers with same browser

In some cases, QA Engineers need to run different methods in parallel on the same servers with same browser. Selenium Grid 2.0 infrastructure supports parallel test execution with TestNG or JUnit. Here are the steps to run different methods in parallel on the same servers with same browser with TestNG.

 

Let's say, you have a computer with IP address 192.168.1.7 :

  • 192.168.1.7 working as a hub and node (can be Linux based or windows based; Lets assume it is a Windows box. )

 Let's start the hub and nodes on the machine 192.168.1.7 (run the command below as an administrator in the command prompt)

java -jar selenium-server-standalone-2.37.0.jar -role hub
Print

Selenium Grid Introduction

Selenium Grid extends Selenium RC by running tests on different servers in parallel or on multiple instance of browsers on the same server. It reduces the time, and subsequently the cost, for testing in various browsers under multiple operation systems.

 

Selenium Grid has two components: Selenium Hub and Remote Control. The hub receives requests from tests (the same as Selenium RC), and then allocates remote controls that are registered to the hub to each tests as shown on the picture below.