Dataprovider: Excel reporting using selenium webdriver.

Class Name:- ExcelReporter.Java

public class ExcelReporter {

private static XSSFWorkbook workbook = null;
private static XSSFSheet sheet = null;
private static XSSFRow row = null;

/*
 * this method creates the header for reporter
 */
static void createReportHeader(String testcaseSheetName) {

    workbook = new XSSFWorkbook();
    sheet = workbook.createSheet(testcaseSheetName);
    row = sheet.createRow(0);

    // row.createCell(0).setCellValue("SNo");
    row.createCell(0).setCellValue("Step No");
    row.createCell(1).setCellValue("Description");
    row.createCell(2).setCellValue("Status");
}

static void flushWorkbook(String testCaseName) throws IOException {
    FileOutputStream fos = new FileOutputStream(new File(System.getProperty("user.dir")+"\\report\\"+testCaseName+".xlsx"));
    workbook.write(fos);
}

static void reportStep(String desc, String status) throws IOException {
    // ArrayList<ArrayList<String>> data1 = DataInputProvider.getSheet("TestSteps","Sheet1");
    row = sheet.createRow(sheet.getLastRowNum()+1);
    row.createCell(0).setCellValue(sheet.getLastRowNum());
    row.createCell(1).setCellValue(desc);
    row.createCell(2).setCellValue(status);

    if(status.toUpperCase().equals("SUCCESS"))
        //ATUReports.add("Pass Step 1", LogAs.PASSED, new CaptureScreen(ScreenshotOf.DESKTOP));
    ATUReports.add("Enter the URL", "Kalyan", "Kumar", "Sample", LogAs.PASSED, new CaptureScreen(ScreenshotOf.BROWSER_PAGE));
    else
        ATUReports.add("Enter the URL", "Kalyan", "Sample", "Sample", LogAs.FAILED, new CaptureScreen(ScreenshotOf.DESKTOP));
}


}

Comments

Popular posts from this blog

Native Android Apps Automation with WebDriver Using Appium Mobile Automation tools

Appium Automation tool Desired Capabilities to run on Real Device

iOS Mobile Automation using Appium Automation tool for Native and Hybrid Application