https://bz.apache.org/bugzilla/show_bug.cgi?id=58495
Bug ID: 58495
Summary: Rowcount returned is zero even when there rows of data
in the excel.
Product: POI
Version: unspecified
Hardware: PC
Status: NEW
Severity: major
Priority: P2
Component: XSSF
Assignee: [email protected]
Reporter: [email protected]
Sheetname:"Test Suite"
test case Description Runmode
Login http://newtours.demoaut.com/ - login Y
Book a flight Book a flight without changing any options. Y
Logout Logout successfully N
Login test executed successfully because total rowcount returned=4 and the
current row id=1. Before executing Book a flight, the current row id=2 but
rowcount returned=0. As a result, execution stops.
POI code:
public class ExcelReader
{
public String path;
public FileInputStream fis;
public FileOutputStream fos;
static XSSFWorkbook workbook;
static XSSFSheet sheet;
static XSSFRow row;
static XSSFCell cell;
int col_num=0;
int index=0;
public ExcelReader(String path)
{
this.path=path;
try
{
fis = new FileInputStream(path);
workbook = new XSSFWorkbook(fis);
fis.close();
}
catch(Exception e)
{
System.out.println("File not found");
}
}
public int getRowCount(String sheetname)
{
index = workbook.getSheetIndex(sheetname);
if(index==-1)
return 0;
else
sheet = workbook.getSheetAt(index);
int rownum=sheet.getPhysicalNumberOfRows();
return rownum;
}
}
Even though the same sheetname is passed to getrowcount method after executing
'login' test, the rowcount returned is zero because the index is set to -1.
Integer suitetestID = new Integer(2);
Integer casetestid = new Integer(2);
Integer steptestid = new Integer(2);
Integer datatestid = new Integer(2);
public SuiteDriver() throws Exception
{
read = new ExcelReader("C:\\Learning_Framework\\xls\\testsuite.xlsx");
}
public void suite1()
{
try
{
while(suitetestID.intValue()<=read.getrowcount(Constants.test_suite_sheet))
{
tid=suitetestID;
System.out.println("Number of rows in suite(before)"+read.getrowcount("Test
Suite");
suite_runmode = read.getcelldata(Constants.test_suite_sheet,
tid,Constants.runmode);
if(suite_runmode.equals(Constants.runmode_yes))
{
suitetestID++;
//Stores the test name
testcase=read.getcelldata(Constants.test_suite_sheet,tid,
Constants.test_suite_sheet_test_case_col);
System.out.println("Suite T/F "+" "+(suitetestID<=read.getrowcount("Test
Suite")));
//Here, the output is 4
testcaseDriver(testcase); -->Passes login String to another method to perform
login actions.
System.out.println("Number of rows in
suite(after)"+read.getrowcount(Constants.test_suite_sheet));
//Here, the output is 0
}
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]