About - Selenium


Development and Versions


Languages supported

Manual vs Automation

Choosing Selenium

Selenium - Components

Selenium IDE

Selenium RC

Selenium WebDriver

Selenium Grid


Selenium vs QTP

Selenium - IDE


Install and configure

Selenium - Webdriver

About WebDriver

install and configure

First test case

Web element

Element Locators

Example of locators


Web driver commands

Eclipse and TestNG

About Eclipse

Choose and download

About TestNG

Testng installation on eclipse

Testng Annotations

Pass Fail and Skip test cases

Run test cases in batch

testng.xml - Explanation

testng grouping

Running tests parallely




Passing parameters

Data providers

Read data from excel

Ant - XSLT reports

Testng listeners

Cross browser testing

Page Object Model

Selenium - Data providers
If we want to pass bulk data to the test method (generally happens in Live selenium projects), we need to use Dataprovider annotations as follows:

Suppose you want to test login process for 3 users, then you have to write 3 Test methods each for 1 user as follows:

Public void loginUser1() {
// The following is email 1
// The following is password of user1

The above process is only for 1 user.
Now for other 2 users, the code looks like this:

// The following is user 2
Public void loginUser2() {
// The following is email 2
// The following is password of user2

Public void loginUser3() {
// The following is email 3
// The following is password of user3

What if we have 100 users, you have to code this 100 times, So to avoid the redundancy we have DataProvider annotations

Now we will see how to write a DataProvider method and how to use that in a @Test method
Public Object [][] testData1(){
Object [][] obj= new Object [][];
//passing data into Object [][]'
obj [0][0]= "ananda1@gmail.com";
obj [0][1]= "pass1";

obj [1][0]= "ananda2@gmail.com";
obj [1][1]= "pass2";

obj [2][0]= "ananda3@gmail.com";
obj [2][1]= "pass3";
return obj;


Explanation of the above code;
What are doing is

a) creating a method testData1 which is annotated with @DataProvider which means the following testData1 method provides data for test cases.
b) The return type of this testData1 method is Object [][], which means 2 dimensional data is returned. In our example we have 3 rows of data each for ananda1, ananda2 and ananda3. Each row has 2 columns as follows: email and password.
c) So for setting these 3 rows of data we can follow this way.

obj [0][0]= "ananda1@gmail.com";
obj [0][1]= "pass1";

d) Finally this method should return the obj, which contains data which is done through return obj.

e) So totally this method, sets the data and returns data in the form of double dimensional array in the form of rows and columns.

f) Now to use this DataProvider, we can achieve with the following code:

@Test (dataProvider="testData1")
Public void login (String email, String password) {
System.out.println ("email:"+email);
System.out.println ("password:"+ password);

Here the full code is not present. In the above code, email and password is printed for three times for three sets of data corresponding to each set.

I conduct online tutions on Manual Testing, Selenium and the following. For more details contact anandaibmindia@gmail.com
Manual Testing - 1600/-           Selenium - 1600/-
           Jsp and Servlet -2000/-           Java training - 2000/-