In last chapter, we created Action Keywords and placed them in to the ‘DataEngine‘ excel sheet, now we need Apache POI in place to connect with the excel sheet in the Selenium Test.


Set Up Data Engine – Apache POI (Excel)

We need a way to open this Excel sheet and read data from it with in this Selenium test script. For this purpose, I use the Apache POI library, which allows you to read, create and edit Microsoft Office-documents using Java. The classes and methods we are going to use to read data from Excel sheet are located in the ‘org.apache.poi.hssf.usermodel’ package.


Reading Data from Excel

  1. Download JAR files‘ of Apache POI. You can download Apache POI Jar files from here.  Note: The latest version in Sep’14 is ‘poi – 3.10.1
  2. Once you downloaded the JAR files, then ‘Add Jars  files to your project library. That’s all about configuration of Apache POI with eclipse. Now you are ready to write code.
  3. Create a ‘New Package and name it as ‘utility’, by right click on the Project folder and select New > Package.
  4. Create a ‘New Class‘ file, by right click on the ‘utilityPackage and select New > Class and name it as ‘ExcelUtils‘. First we will write basic read method.