Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce

» Selecting the input for auto populating element
Sat Jul 29, 2017 7:53 pm by kdabbara

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