Cross Browser Testing: Using Selenium Grid

ByAnurag Sogani
January 25th . 5 min read
Cross Browser Testing: Using Selenium Grid

According to the latest stats, Chrome is acquiring 60.98%, Internet Explorer by 12.18%, Firefox by 11.47% and Safari by 3.72% of total market shares in the browser uses. Different users use different versions of browsers to open a website as per their comfort levels. Imagine when your websites don’t provide the same user experience with different combinations of browsers and OS. It will be a major drawback for your business, and you do not want that to happen.

On different browsers, a website provides different user experiences. Cross-Browser testing is the procedure of comparing a site or web app’s design and functionality across different platforms and web browsers to make sure consistent functionality and behaviour for the end-user. With so many varieties of web browsers, operating systems and devices, obtainable today, cross-browser testing has become a critical part of software development.

What to Test?

In this blog, we are going to discuss the role of cross-browser compatibly. With cross browser testing, we can test our website in all available browsers with different versions to provide same experience to our users everywhere.

  • Base Functionality: Links, dialogs, menus etc.
  • Graphical User Interface: Look and feel of the application.
  • Response: How well the website provide response on user inputs.
  • Performance: Loading of the pages within allowed the time frame.

How to do Cross-Browser Testing?


There are two possible options available for cross browser testing as shown in the above image-

  • Manual: Perform all test case manually on different combination of operating system and Web Browsers.
  • Automation: Using Selenium Grid.

Selenium Grid

Selenium Grid is a part of Selenium suite which is used for executing test scripts, or we can say test cases across different systems, operating systems and web browser in parallel process. Mainly, there are two versions of Selenium Grid-

  • Newer Selenium Grid
  • Older selenium Grid

Advantages of Selenium Grid:

  • Used to perform test scripts parallelly in distributed way.
  • Can perform multi-browser testing.
  • Reduces batch processing time.
  • Can perform multi-operating system testing.

Selenium Grid Architecture:

Selenium Grid works on the Hub-Node Principle. There is machine, or we can say a System that is called Hub, the centre part of the Selenium Grid. All the scripts will be executed from Hub. All the systems, where we want to execute our scripts, called NODE. These nodes are handled by the Hub remotely.


How to Set-up Selenium Grid??

For configuration of selenium grid, firstly, we have to download selenium Java client Driver, which is a Jar file. Currently, its stable version is 3.141.59. Like we have stated earlier, Grid is working on the principle of HUB-Node. Let’s assume here, machine A is hub and Machine B is Node.

Now, put this Jar file in C drive of the machine A and B.

  • Step 2– Open the command prompt and navigate to the location where selenium server/jar file is placed.
  • Step 3– Execute following Command on Command Prompt: java –jar selenium-server-standalone-2.43.1.jar –role hub

The screen should now look something like this-


  • Step 4- We can also verify whether the hub is running, by using a browser. Selenium Grid generally use port number 4444 for running Grid. Simply open up a browser and go to: http://localhost:4444/grid/console
  • Step 5– For now, the hub is set, now we have to launch a node. On the Machine B, open a Command prompt.

Move to Drive C and run the code given-below. Here, we have worked with the IP address because our hub is processing from there only. We can use any port number as well. For Ex. We used 5566 here-

java -jar selenium-server-standalone-3.4.0.jar -role webdriver -hub -port 5566


  • Step 6– Now, move to Machine A, refresh selenium web interface, and you will see the following screen.


At the time, we have set up a simple grid with a NODE on machine B, which is controlled by Hub, on machine A.

Now we move to the Gris’s web interface, hover on the icon of the browser that will be automated. We can note the platform name and Browser name shown by hovering.

Sample Grid Code:

Create Hub and nodes as explained earlier and TestNG should be configured in eclipse. Here, we have taken a sample test to login to Gmail and enter username and password.

public class GridExample {
         public void mailTest() throws MalformedURLException{
                 DesiredCapabilities dr=null;
                 nodeURL1 = “<a href=""></a>”;
                 nodeURL2 = “<a href=""></a>”;
                 RemoteWebDriver driver=new RemoteWebDriver(new    URL(nodeURL1), dr);
                 driver.findElement(By.xpath("//input[@id='Email']")) .sendKeys("username");
                 driver.findElement(By.xpath("//input[@id='Passwd']")) .sendKeys("password");
                                   RemoteWebDriver driver=new RemoteWebDriver(new    URL(nodeURL2), dr);
                 driver.findElement(By.xpath("//input[@id='Email']")) .sendKeys("username");
                 driver.findElement(By.xpath("//input[@id='Passwd']")) .sendKeys("password");

The above code launches chrome browser and navigates to the URL specified in the nodeURL1 and nodeURL2.

To execute test scripts on the Grid, we require two objects, the first one is DesiredCapabilities and the second is RemoteWebDriver object.

  • DesiredCapabilites is used to choose the browser and OS that we will automate.
  • RemoteWebDriver is used to choose node in the network where our test scripts will run.


So, in this blog, we have understood the cross-browser testing using Selenium Grid. Now you can easily your website in all available browsers with different versions to provide the same experience to our users everywhere with the help of cross-browser testing.

Here you can know the steps to Install Selenium Webdriver in Eclipse IDE and Create Selenium Webdriver project by visit on it. Hope this information will be helping you and your growth also.

Keep in touch with us for more blogs.