What is Data Driven Framework
Selenium Webdriver Data-Driven Framework is where test input and output values are from data files (ODBC sources, CVS files, Excel files, and DAO objects) and are loaded into variables in captured or manually coded scripts.
In this framework, variables are used for both the input values and output verification values. The framework should include navigation through the program, reading of the data files, and logging of test status and information. All the processes should be in the test scripts. The framework should have the following features:
Steps :
1. Download apache poi form https://poi.apache.org/download.html link.
2. Unzip and import jar your project.
3.Use given API to connect to excel sheet
Selenium Webdriver Data-Driven Framework is where test input and output values are from data files (ODBC sources, CVS files, Excel files, and DAO objects) and are loaded into variables in captured or manually coded scripts.
In this framework, variables are used for both the input values and output verification values. The framework should include navigation through the program, reading of the data files, and logging of test status and information. All the processes should be in the test scripts. The framework should have the following features:
- Well defined architectural design
- Less time to test large data
- Script execution in multiple environments
- Easier, faster, and efficient analysis of result logs
- Communication of results
- Easy debugging and scrip tmaintenance
- Robust and stable due to error and exception handling
- 100% reliability of utility scripts, online execution and report packages.
Framework Architecture Design
Automation architecture package should include:- Config - Keeps all the configuration files such as property files
- InputTestData - has files containing input data for application
- OutputData - Contains downloaded documentations, images, fetched data in excel
- TestReports - Contains ANT generated reports
- Util package - Should contain all generic functions & business functions such as email configuration settings and all other utilities
- TestLogs-Contain log file corresponding to tests
- DAO - Classes for accessing persistent storage, such as to a database
- Pages - Page classes for particular pages
How to connect Excel Sheet Using Selenium Web driver.
To get data from excel sheet or write data in excel sheet we require some other api which available on below link:Steps :
1. Download apache poi form https://poi.apache.org/download.html link.
2. Unzip and import jar your project.
3.Use given API to connect to excel sheet
- For Reading and write the data from excel sheet
public class BasicReadData {
public static void main(String[] args) throws EncryptedDocumentException, InvalidFormatException, IOException
{
File src=new File("Path of excel sheet");
FileInputStream fis=new FileInputStream(src);
Workbook wb= WorkbookFactory.create(fis);
Sheet s=wb.getSheet("Sheet1");
int rowdata=s.getLastRowNum();
//Row r=s.getRow(0);
//Cell c=r.getCell(0);
//System.out.println(c);\
for(int i=0;i<=rowdata;i++)
{
String string0=s.getRow(i).getCell(0).getStringCellValue();
System.out.println(string0);
}
s.getRow(0).createCell(2).setCellValue("nishnt");
FileOutputStream fout=new FileOutputStream(src);
wb.write(fout);
}
}
public static void main(String[] args) throws EncryptedDocumentException, InvalidFormatException, IOException
{
File src=new File("Path of excel sheet");
FileInputStream fis=new FileInputStream(src);
Workbook wb= WorkbookFactory.create(fis);
Sheet s=wb.getSheet("Sheet1");
int rowdata=s.getLastRowNum();
//Row r=s.getRow(0);
//Cell c=r.getCell(0);
//System.out.println(c);\
for(int i=0;i<=rowdata;i++)
{
String string0=s.getRow(i).getCell(0).getStringCellValue();
System.out.println(string0);
}
s.getRow(0).createCell(2).setCellValue("nishnt");
FileOutputStream fout=new FileOutputStream(src);
wb.write(fout);
}
}
- Count Cell in each row
public class CountCellinEachRow {
public static void main(String[] args)
{
try{
FileInputStream fis=new FileInputStream("Path of excel sheet");
Workbook wb=WorkbookFactory.create(fis);
Sheet s=wb.getSheet("Sheet1");
int i=s.getLastRowNum();
System.out.println(i);
}
catch(Exception e){
}
}
- Print No. of Cell Present in Excel Sheet
public class PrintNoOfCell {
public static void main(String[] args)
{
try{
FileInputStream fis=new FileInputStream("Path of excel sheet");
Workbook wb=WorkbookFactory.create(fis);
Sheet s=wb.getSheet("Sheet1");
for(int i=0;i<=s.getLastRowNum();i++)
{
int n=s.getRow(i).getLastCellNum();
System.out.println(n);
}
}
catch(Exception e){
}
}
}
This is an excellent post I would say thanks for sharing it for free. This is really what I wanted to read, hope in future you will continue sharing such an excellent articles.
ReplyDeleteBest selenium training in chennai
selenium Classes in chennai