Selenium Tutorial 29: Data Driven Testing in Selenium

preview_player
Показать описание
Data Driven Testing in Selenium tutorial explains Data driven testing by fetching test data from an external excel file. Download excel jar file and add excel jar to Java project in Eclipse, write Selenium Webdriver Test case and execute the Test case using multiple sets of Test data. Usage of TestNG DataProvider annotation.
Рекомендации по теме
Комментарии
Автор

Sir. This is your student Md Rahman from VA. I have learned Java Basic and Selenium webdriver from you and today by the help of almighty GOD and your resources, i have developed common Selenium JUnit Framework for my team and it's just awesome. Thanks for your detailed oriented teaching and efforts. May GOD bless you and your family.

mdrahman
Автор

Sir I am new to your videos..it's been just 2 months that I am following your videos. It's helping me a lot to make my base clear...thank you for sharing the tutorials...will update you my progress ....

kanchanggogoi
Автор

No need to convert the String to int. You can actually receive it in int format.

Assume this are ur excel values--> 1, 2, "Hello world"
U can receive the values as follows

@Test(dataProvider = "xyz")
public void getdata(int a, int b, String c)

martinpdavidseo
Автор

your videos are well clear, you are the best trainer. can you post videos for business analyst, what are the deliverables they need

vijayalakshmi-pynx
Автор

Class Notes:
Selenium Class 29: Data Driven Testing in Selenium

Data Driven Testing using DataProvider

1) Read Test data (String type) from excel file and perform Data driven Testing for Admin Login Functionality.

2) Read Test data (Integer type) from excel file and perform Data driven Testing for Addition Functionality.

1) Read Test data (String type) from excel file and perform Data driven Testing for Admin Login Functionality.

Steps in Admin Login

i) Launch the Browser
iii) Enter User name
iv) Enter Password
v) Click "Login" Button

Verification Point
Capture URL, and compare with expected.


Prepare Test data file.

> Download Excel jar and extract
> Add Excel jar to Java Project in Eclipse

Selenium Test Case:

public class DatadrivenTest {
public WebDriver driver;
@Test(dataProvider ="testdata")
public void login(String username, String password){
driver = new FirefoxDriver();



driver.close();
}

@DataProvider(name = "testdata")
public Object [] [] readExcel() throws BiffException, IOException {
File f = new
Workbook w = Workbook.getWorkbook(f);
Sheet s = w.getSheet("Sheet1");
int rows = s.getRows();
int columns = s.getColumns();
//System.out.println(rows);


String inputData [] [] = new String [rows] [columns];
for (int i=0; i<rows; i++){
for (int j=0; j<columns; j++){
Cell c = s.getCell(j, i);
inputData [i][j] = c.getContents();

}
}
return inputData;
}
}

2) Read Test data (Integer type) from excel file and perform Data driven Testing for Addition Functionality.

public class Datadriven2 {

public void add(String val1, String val2, String val3){
int a = Integer.parseInt(val1);
int b = Integer.parseInt(val2);
int c = Integer.parseInt(val3);
int result = a + b + c;
System.out.println(result);
}

public Object [] [] readExcel() throws BiffException, IOException {
File f = new
Workbook w = Workbook.getWorkbook(f);
Sheet s = w.getSheet("Sheet1");
int rows = s.getRows();
int columns = s.getColumns();
//System.out.println(rows);


String inputData [] [] = new String [rows][columns];
for (int i=0; i<rows; i++){
for (int j=0; j<columns; j++){
Cell c = s.getCell(j, i);
inputData[i][j] = c.getContents();

}
}
return inputData;
}
}

Difference between Reading String type data and Integer type data.

If it is String type data then you can use the data as it is.

If it is Integer type data, convert the data (from String type to Integer type) then use the data.

Why we need to convert the data?

If you read data then Computer program considers the data as String type data,
In order to perform mathematical operations then we need to convert the data.

Assignments

i) After Assert fails then close the Browser. (Madhavi)

ii) Read data from excel (range of records) -(Rahman)

Assignments

i) Verify "Telephone Number" field in Customer registration form.

Enter valid inputs for all fields except "Telephone Number" and click

Capture error message and compare with expected.

Write exception.

Data has 3 factors

Type (Alfa bytes, numeric, Alfa-numeric etc...)
Size (10 digits)
Range (25 to 30 Years, 30 to 35 Years ....)


Check Email format
Or

iii) Verify the Date field(Date of Birth:) in customer Registration form

Project Automation

Selenium WebDriver + Programming (Java) + Testing Framework(JUnit/TestNG)
Or
Selenium WebDriver + Programming (C#) + Testing Framework(NUnit)
Or
Selenium IDE
Or
Selenium WebDriver + Programming (Java)

gcreddy
Автор

I am getting this error jxl.read.biff.BiffException: Unable to recognize OLE stream

MrSuhas
Автор

Thank you for such a wonderful lecture,
Sir my code is running very fine.
Sir how you managed to close all the windows at once...
@Afterclass method also not working...Please help

rakeshjoshi
Автор

Hello Reddy sir as you explain how to read excel but it will fetch all the row and and all the column but in my excel sheet i have test case id in 1st column and test description in 2nd column and data in 3rd column so i want a dynamic method where i will apply for loop for the row and column whichever column i specify it should read that column only . how i can do that please help me out with that.

sauravkumar
Автор

Hi sir thanks for this i want to know these 30 video are enough for selenium testing .for getting job.?

vijaygour
Автор

I get  below error when I typed the same video. Should I add library?The method getWorkbook(File) is undefined for the type WorkbookThe method getRows() is undefined for the type Sheet

kieunguyen
Автор

I am getting this exception while run to the program "Exception in thread "main" jxl.read.biff.BiffException: Unable to recognize OLE stream"

pradeeppandey
Автор

Hi, Thanks for the video, can you make a simillar video using apache poi,
Thanks

abdulnawas
Автор

Sir i have problem in path set to excel file, Eclipse respond an Exception "Exception in thread "main" ‪‪F:\Tool\ExcelData\New Text Document.txt (The filename, directory name, or volume label syntax is incorrect)".What is the reason, can u help me

ajin
Автор

hello sir,
how can we do by using POM.
how to call this method in our POM testcase

apoorvasrivastava
Автор

Sir,

We can implement "if" and "else" condition in TestNG??

yogeshchugh
Автор

while following code in this video i got this error sir please help me to solve this :

Error: Main method not found in class sampleselenium.Datadriven, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend

Californiavideos
Автор

Hello Sir, Namaste .
By following your videos only i learnt Selenium, Thanks a lot for the videos sir.
I'm getting below error in data driven testing .

The ERROR IS : The data provider is trying to pass 28 parameters but the method addTalent.AddTalent#addtalent takes 20

Is there any solution for this sir?

Pls help me in this Regard .

Thank you in advance sir.

CEOBYCHOICE
Автор

is it possible to get access to the assignments please?

pooutube
Автор

C:\Users\Kartik Creation\Desktop\Data.xls (The system cannot find the file specified)

I am getting this error. i have used jxl library for xls format Please can you please provide suggestion

prashantmasekar
Автор

sir can we do the above video in junit using selenium webdriver

jenitorthomson
visit shbcf.ru