Selenium Java Data Driven Automation - How to Read Data from Excel File

Publié le: 13 février 2026
sur la chaîne: Lets Learn QA
188
12

Selenium Java Data Driven Automation - How to Read Data from Excel File

Step 1 = Create a Maven Project

Step 2 = Add Apache POI dependencies in POM.xml file
Apache POI
Apache POI ooxml

Step 3 - Create an excel file and save it.

Step 4 - Create object of FileInputStream to read the file.
FileInputStream fs = new FileInputStream("F:\\TestData\\SampleData.xlsx");

Step 5 - //Creating a workbook
XSSFWorkbook workbook = new XSSFWorkbook(fs);

Step 6 - //Identify Worksheet in workbook
XSSFSheet sheet = workbook.getSheetAt(1);

Step 7 - //Get the Row from worksheet
Row row = sheet.getRow(0);

Step 8 - //Get the cell from the Row Reference
Cell cell = row.getCell(0);

Step 9 - //Get the value from the cell.
System.out.println(cell.getStringCellValue());

//System.out.println(sheet.getRow(0).getCell(0));
//System.out.println(sheet.getRow(0).getCell(1));

Step 10 - //How to count total columns getLastCellNum()
System.out.println(sheet.getRow(0).getLastCellNum());

Step 11 - //How to count total Rows
System.out.println(sheet.getLastRowNum());




#javaconcepts #javainterviewquestionsanswers #seleniumjava
#datadriven #automationtesting #automationtestinginterviewquestions
#qatraining #letslearnqa


Sur cette page du site, vous pouvez voir la vidéo en ligne Selenium Java Data Driven Automation - How to Read Data from Excel File durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Lets Learn QA 13 février 2026, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 188 fois et il a aimé 12 téléspectateurs. Bon visionnage!