RE: if i have 50 test cases in my excel sheet…i want only first 20 test cases to be executed by using excel driven framework…then how can i do this?


Need urgent help for interview…..

snpanigrahi9 Train Asked on December 16, 2014 in Selenium WebDriver.
Add Comment
1 Answers
Best answer

Refer the below code snippet:

Sheet  sheet =  Workbook.getSheet(sheetName);

//Find number of rows in excel file

int rowCount =  sheet.getLastRowNum()- sheet.getFirstRowNum();

//Create a loop over all the rows of excel file to read it

for (int i = 0; i < rowCount+1; i++) { //Here you can choose how many times the loop need to be run 20 in ur case.

Row row =  sheet.getRow(i);

//Create a loop to print cell values in a row

for (int j = 0; j < row.getLastCellNum(); j++) {

//Print excel data in console

System.out.print(row.getCell(j).getStringCellValue()+”|| “);

Supporter Answered on December 18, 2014.


on December 22, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.