Search
 
 

Display results as :
 


Rechercher Advanced Search

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

how to print row wise data executing all @test methods for each row in excel sheet

View previous topic View next topic Go down

how to print row wise data executing all @test methods for each row in excel sheet

Post by karthik palicherla on Tue Sep 29, 2015 6:40 pm

package DataProvider;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.SimpleDateFormat;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.openqa.selenium.By;
import org.testng.annotations.Test;

public class Sample 
{
 @Test ( priority=0)
 
  public void borrowerObligation() throws InterruptedException, IOException
 
 {

    FileInputStream file1 = new FileInputStream(new File("D://Users//kpaliche//Desktop//Selenium//Sample1.xls"));
    HSSFWorkbook workbook = new HSSFWorkbook(file1);
    HSSFSheet sheet4 = workbook.getSheetAt(0); 

    int rowcount=sheet0.getLastRowNum();
    System.out.println("sheet0 :"+rowcount);
    for (int i=1 ; i <= rowcount ; i++){
    System.out.println(String.valueOf(Math.round(sheet4.getRow(1).getCell(0).getNumericCellValue())));
    System.out.println(String.valueOf(Math.round(sheet4.getRow(1).getCell(1).getNumericCellValue())));
    System.out.println(sheet4.getRow(1).getCell(2).getStringCellValue());
    System.out.println(String.valueOf(Math.round(sheet4.getRow(1).getCell(3).getNumericCellValue())));
    System.out.println(String.valueOf(Math.round(sheet4.getRow(1).getCell(4).getNumericCellValue())));

   }}  // @Test ( priority=0)

  @Test ( priority=1)
 
  public void financials() throws InterruptedException, IOException
 
  {

   FileInputStream file1 = new FileInputStream(new File("D://Users//kpaliche//Desktop//Selenium//Sample1.xls"));
  HSSFWorkbook workbook = new HSSFWorkbook(file1);
  HSSFSheet sheet1 = workbook.getSheetAt(1); 
  int rowcount=sheet1.getLastRowNum();
   System.out.println("sheet1 :"+rowcount);

   for (int i=1 ; i <= rowcount ; i++){


   System.out.println(sheet1.getRow(1).getCell(0).getStringCellValue());

   System.out.println(new SimpleDateFormat("MM/dd/yyyy").format(sheet1.getRow(1).getCell(1).getDateCellValue()));
             

   System.out.println(String.valueOf(Math.round(sheet1.getRow(1).getCell(2).getNumericCellValue())));
   
   System.out.println(String.valueOf(Math.round(sheet1.getRow(1).getCell(3).getNumericCellValue())));
      
   System.out.println(String.valueOf(Math.round(sheet1.getRow(1).getCell(4).getNumericCellValue())));
        
 
  }}

 
  
 
 
}

karthik palicherla

Posts : 2
Join date : 2015-01-29

Back to top Go down

Re: how to print row wise data executing all @test methods for each row in excel sheet

Post by murthi on Fri Apr 15, 2016 8:35 pm

You can use data providers. Then Iterate throw each row....

murthi
Active particpant
Active particpant

Posts : 11
Join date : 2016-04-14
Location : Bangalore

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum