How to use Dataprovider Annotation in Selenium TestNG

If you want to provide the test data, the DataProvider way, then we need to declare a method that returns the data set in the form of two dimensional object array Object[][]. The first array represents a data set whereas the second array contains the parameter values.
The @Test method that wants to receive data from this DataProvider needs to use a dataProvider name equals to the name of this annotation.

Here I am providing a sample snippet

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
import org.testng.annotations.DataProvider;

public class dataprovider

public String[][] login()
return new String[][]{

@Test (dataProvider=”datainput”)

public void login1(String uid, String pass)
WebDriver fd=new FirefoxDriver();


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s