Next-Gen App & Browser Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Apache POI is a Java library used in Selenium to read, write, and manipulate Excel files (.xls and .xlsx) for data-driven testing. Because Selenium WebDriver cannot handle spreadsheets on its own, this third-party API lets your automation scripts pull test inputs from Excel and log results back, keeping test data separate from code and easy to maintain.
POI stands for Poor Obfuscation Implementation, an open-source project from the Apache Software Foundation that provides a pure-Java API for Microsoft Office formats. Selenium WebDriver, by contrast, is built to drive a browser and knows nothing about files on disk, so it has no methods to open a workbook or read a cell. Whenever a test needs to run the same steps against many input combinations, storing those combinations in Excel and reading them with Apache POI is the standard solution. This keeps the TestMu AI Selenium WebDriver script generic while the data lives outside it, so adding a new test case means adding a row, not editing code.
Apache POI exposes different implementations depending on the file format and size:
First add the dependency, then open the workbook and walk the sheet. With Maven, the two modules you need are poi and poi-ooxml:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.5</version>
</dependency>This snippet reads every cell of the first sheet and prints its value, which you would feed into your Selenium test:
FileInputStream file = new FileInputStream("testdata.xlsx");
Workbook workbook = new XSSFWorkbook(file);
Sheet sheet = workbook.getSheetAt(0);
DataFormatter formatter = new DataFormatter();
for (Row row : sheet) {
for (Cell cell : row) {
String value = formatter.formatCellValue(cell);
System.out.print(value + " | ");
}
System.out.println();
}
workbook.close();
file.close();Writing follows the reverse path: create a workbook and sheet in memory, add rows and cells, then flush to a FileOutputStream.
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("Results");
Row row = sheet.createRow(0);
row.createCell(0).setCellValue("TestCase");
row.createCell(1).setCellValue("Status");
FileOutputStream out = new FileOutputStream("results.xlsx");
workbook.write(out);
workbook.close();
out.close();Combined with TestNG's DataProvider, these read and write helpers turn a single script into a full data-driven Selenium automation suite.
Apache POI supplies the data, but the value of data-driven testing comes from running each dataset against many environments. With TestMu AI, you can execute the same POI-fed Selenium suite across 3000+ real browsers, devices, and operating systems in parallel, so every row of your Excel file is validated on the platforms your users actually use. This pairs naturally with scalable automation testing and true cross browser testing, turning a spreadsheet of inputs into broad, reliable coverage without maintaining your own grid.
Apache POI is the bridge that lets Selenium work with Excel, which is why it is a staple of data-driven test frameworks. Use XSSF for modern .xlsx files, read inputs through Workbook, Sheet, Row, and Cell, write results back for reporting, and keep all your POI modules on one version to avoid classpath errors. Layer that on a real-device cloud, and your spreadsheet of test data scales into comprehensive, cross-platform coverage.
Selenium WebDriver automates browsers but has no ability to read or write Excel files. Apache POI is a third-party Java library that fills that gap, letting your tests pull input data from spreadsheets and log results back, which is the foundation of data-driven testing.
HSSF handles the older binary .xls format (Excel 97-2003), while XSSF handles the XML-based .xlsx format (Excel 2007 and later). For very large files, SXSSF streams data to keep memory use low. Most modern projects use XSSF because .xlsx is the current standard.
No. Apache POI is a separate open-source library maintained by the Apache Software Foundation. It is added to a Selenium project as a dependency, usually through Maven or Gradle, and works alongside WebDriver rather than being bundled with it.
Open the file with a FileInputStream, create a Workbook, then navigate to the Sheet, Row, and Cell you need. A DataFormatter converts each cell to a readable String regardless of type, which you then feed into your Selenium test as input data.
A NoSuchMethodError almost always means mismatched POI jar versions on the classpath. Apache POI's modules must all share the same version, so align poi and poi-ooxml, remove duplicate jars, and rebuild. Using a single managed version through Maven usually resolves it.
Yes. Apache POI can return either the cached result of a formula or evaluate it at runtime using a FormulaEvaluator. For test data you usually want the computed value, so evaluate the cell and then read it as a numeric or string result before passing it to Selenium.
KaneAI - Testing Assistant
World’s first AI-Native E2E testing agent.

TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance