Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
karthik palicherla
Posts : 2
Join date : 2015-01-29

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

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())));
        
 
  }}

 
  
 
 
}
avatar
murthi
Active particpant
Active particpant
Posts : 11
Join date : 2016-04-14
Location : Bangalore

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

Fri Apr 15, 2016 8:35 pm
You can use data providers. Then Iterate throw each row....
Back to top
Permissions in this forum:
You cannot reply to topics in this forum