Recall & Review
beginner
What is Apache POI used for in Selenium Java testing?
Apache POI is a library used to read and write Microsoft Excel files in Selenium Java tests. It helps automate data-driven testing by accessing test data stored in Excel sheets.
Click to reveal answer
beginner
Which Apache POI class is used to read an Excel workbook (.xlsx)?The <code>XSSFWorkbook</code> class is used to read and write Excel workbooks with the .xlsx format.Click to reveal answer
beginner
How do you get a sheet from a workbook using Apache POI?
Use
workbook.getSheet("SheetName") or workbook.getSheetAt(index) to get a specific sheet from the workbook.Click to reveal answer
intermediate
What is the correct way to read a cell value as a string in Apache POI?
Use
cell.getStringCellValue() if the cell type is STRING. For other types, convert accordingly to avoid errors.Click to reveal answer
beginner
Why should you close the FileInputStream after reading an Excel file with Apache POI?
Closing the FileInputStream frees system resources and avoids file locks, ensuring other processes can access the file safely.
Click to reveal answer
Which class do you use to open an Excel .xlsx file in Apache POI?
✗ Incorrect
XSSFWorkbook is used for .xlsx files, while HSSFWorkbook is for older .xls files.
How do you get the number of rows in a sheet using Apache POI?
✗ Incorrect
getPhysicalNumberOfRows() returns the count of physically defined rows.
What happens if you try to read a numeric cell with getStringCellValue()?
✗ Incorrect
getStringCellValue() throws an exception if the cell type is not STRING.
Which method closes the workbook and releases resources in Apache POI?
✗ Incorrect
workbook.close() properly closes the workbook and frees resources.
Why is Apache POI preferred for Excel data reading in Selenium tests?
✗ Incorrect
Apache POI supports .xls and .xlsx formats and is free to use.
Explain the steps to read data from an Excel file using Apache POI in Selenium Java.
Think about opening the file, accessing sheets, reading cells, and closing resources.
You got /6 concepts.
What are common pitfalls when reading Excel data with Apache POI and how to avoid them?
Consider errors from data types and resource management.
You got /5 concepts.