Selenium testNG Parametrization – Parameters and dataProvider

TestNG provides a way to get the data from external sources like from excel/textfile/arrays which helps to prepare data driven framework in automation.

@Parameters – pass parameters from the testNG.xml

@dataProvider – Pass the parameters as a 2D array.

Let’s see the code implementation


and the testng.xml looks like:


so we have 3 parameters to pass to our method, so we have given 3 parameter tags in testNG.xml,
even we can send any type of data type as parameter value like integer, character, string, boolean etc.


This is another way of passing 2 dimensional array as parameter from a method of same or from different class, let’s see one by one.

the @Test method will run number of times depends on the number of data sets provided in the object array.

From same class

Let’s say we have the public Object[][] dataProviderArr() method defined in another class (dataProviderArray.class), then we can write:

From another class

The TestNG.xml looks like (for from same and another class)

Let’s see some more details about the testNG, @Test annotation attributes

Content posted is based on learning or working experience,
Share the post with others if find useful,
Any queries?, leave comments or discuss on our, Thanks!

1 Response

  1. November 1, 2016

    […] Let’s get into bit more depth about testNG, refer testNG parameterization […]

Leave a Reply

Your email address will not be published. Required fields are marked *