top of page

Basics of Cross Browser Testing in Selenium WebDriver using TestNG Parameters

Whenever a new website or application is developed it is necessary to test the functionality of the particular website in different browsers before it is moved to the market.

Cross Browser Testing:

Cross browser Testing is the process of verifying the functionality of the Website in multiple commonly used browsers like Chrome, Safari, Firefox, Edge, IE and operating systems. In other words, Cross browser Testing is a type of functional test that your web application works as expected in different browsers. Using Cross browser testing we can check that the website is rendered the same in different browsers.

How can Cross Browser Testing performed?

In Scrum everyone should perform Cross Browser Testing . It will be a complete responsibility of QA or Software Tester. Cross Browser Testing can be performed either Manually or Automatically.

Manual Cross Browser Testing:

In Manual Testing we use multiple machines with different browsers installed and have to consider different versions and Operating Systems.


  • It will be a tedious process

  • Time consuming

  • Chances of getting human error

Automated Cross Browser Testing:

Its always better to go with Automated Cross Browser Testing. We can perform Automated Cross Browser Testing with the help of Selenium and TestNG parameters. Parallel execution can also done by using Automated Cross Browser Testing .


  • Run time is less

  • Prevent issue arising by human error

Importance of Cross Browser Testing:

Browser Vendors follow open web standards but they have their own interpretations of them, which includes

  • Font size mismatch

  • Variation in Java Script Implementation

  • Variation in CSS ,HTML validation

  • Variation in page alignment, div size and image orientation

  • Browser incompatibility with Operating System

Cross browser Compatibility testing helps the web developers to abstract browser differences by showing the browser specific compatibility errors. So that they can fix the issue quickly. In Short, We need to ensure that the Web application will work as expected in all popular browsers so that more users can accept it and use it.

How can we achieve cross browser testing in Selenium?

We can integrate TestNG framework with Selenium WebDriver to execute test cases with different browsers in the same machine at the same time. The TestNG Parameters helps us to pass different values to the same function. TestNG parameters helps to avoid code repetition and the TestNG annotations are used to control the next method to be executed in the Test script .

Steps to be followed to perform Cross Browser Testing in Selenium:

Step 1: Write the test cases and the test cases be automated with commonly used browsers with the help of Selenium WebDriver.

Step 2: To execute the Testcases with different browsers we have to integrate TestNG Framework with Selenium WebDriver

package crossbrowser;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import io.github.bonigarcia.wdm.WebDriverManager;

public class CrossbrowserTesting {

	WebDriver driver;

	public void Initializebrowser(String browserName) {
		System.out.println("Browser Name is :" + browserName);

		if (browserName.equalsIgnoreCase("Firefox")) {
			driver = new FirefoxDriver();
		} else if (browserName.equalsIgnoreCase("Chrome")) {
			driver = new ChromeDriver();

		} else if (browserName.equalsIgnoreCase("Edge")) {
			driver = new EdgeDriver();
		} else {
			throw new RuntimeException("BrowserType Not Supported");



	public void test1() {
		System.out.println("Test completed Successfully");

	public void Teardown() {


Here I Wrote a simple test case to open the Selenium Website with Firefox, Chrome and Edge browsers and to execute the test cases Integrated with TestNG parameters.


If we add the WebDriverManager Dependency in POM.xml and import the WebDriverManager then the WebDriver itself set the browser path .


import io.github.bonigarcia.wdm.WebDriverManager;             

Step 3: Create the testng.xml file to run the test cases. Right click the class you created in my case it is CrossbrowserTesting--->TestNG---->Convert to TestNG

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "">
<suite name="Suite1" thread-count="3" parallel="tests">
  <test name="Testing Firefox">
  <parameter name="browserName" value="Firefox"></parameter>
      <class name="crossbrowser.CrossbrowserTesting"/>
  <test name="Testing Chrome">
  <parameter name="browserName" value="Chrome"></parameter>
      <class name="crossbrowser.CrossbrowserTesting"/>
  <test name="Tesing Edge">
  <parameter name="browserName" value="Edge"></parameter>
      <class name="crossbrowser.CrossbrowserTesting"/>
</suite> <!-- Suite1 -->

In xml.file we need to add "Parallel" in Suite level so that all the browsers can open up parallelly .

Step4: Run the testng.xml file

Right click---->Run As---->TestNG Suite

Console output:

Results of running suite:

Step5: To get the TestNG reports

Refresh the project .Go to test-output--->emailable_report.html


Hence all the 3 test cases are passed successfully and open the selenium website in 3 different browsers.

So we conclude that Cross Browser Testing is essential for the development of any website so that the website can open in any device ,any OS, any version. Hope you get some basics of cross browser Testing through this Blog. Happy learning!

170 views0 comments

Recent Posts

See All

Java Streams Java Streams are a sequence of elements that represent a pipeline through which data flows. They allow you to perform different operations on data elements, such as filtering, mapping, an

bottom of page