Handling Excel Files Using Apache POI In Selenium WebDriver
Handling excel files Using Apache POI in Selenium WebDriver. As we all know Selenium supports only Web browser automation. We need to get the help of third party API like Apache POI to handle (read and write) excel files using Selenium WebDriver.
What is Apache POI?
Apache POI is an open source library developed and distributed by Apache Software Foundation to design or modify Microsoft Office files using Java program. It is a popular API that allows to work around excel files using Java Programs. In short, you can read and write MS Excel files using Java. Apache POI is your Java Excel solution.
You’d use HSSF if you needed to read or write an Excel file using Java (XLS). You’d use XSSF if you need to read or write an OOXML Excel file using Java (XLSX). It has many predefined methods, classes, and interfaces.
Official website of Apache POI
List of different Java Interfaces and classes in POI for reading XLS and XLSX file
Workbook: HSSFWorkbook and XSSFWorkbook classes implement this interface
HSSFWorkbook: It is a class represents XLS file
XSSFWorkbook: It is a class represents XLSX file
Sheet: HSSFWorkbook and XSSFWorkbook classes implement this interface
HSSFSheet: It is a class represents a sheet in a XLS file
XSSFSheet: It is a class represents a sheet in a XLSX file
Row: HSSFWorkbook and XSSFWorkbook classes implement this interface
HSSFRow: It is a class represents a row in a sheet of XLS file
XSSFRow: It is a class represents a row in a sheet of XLSX file
Cell: HSSFWorkbook and XSSFWorkbook classes implement this interface
HSSFCell: It is a class represents a cell in a row of XLS file
XSSFCell: It is a class represents a cell in a row of XLSX file
Download link of Apache POI Jars.
Download the jar files using the above mentioned link. All jar files will come in a zip file. Extract it and Add all jar files in the Project.
Must Read: How To Install Apache ANT
Note: How to add Jar files – Select Project and Right click on the Project – Go to ‘Build path’ – Go to ‘Configure build path’ – Click on ‘lib’ section – Add external jar
We do handle excel files using Apache POI in Selenium WebDriver very often. Mainly coming to Automation framework (Data Driven Framework), we call the data from excel file and write the data in the excel file. Below links give an idea about Read/Write excel files using Selenium WebDriver.
How to Read Excel Files Using Apache POI In Selenium WebDriver
How to Write Excel Files Using Apache POI In Selenium WebDriver
If you are not regular reader of my blog then I highly recommend you to signup for the free email newsletter using the below link.
Can you tell,how to explain Keyword driven frame work in Interview?
Hi Satish, earlier I have clearly explained hybrid framework check this link for that. Whatever framework it is you just follow the way I did in that. Coming to keyword driven, I will try to write a separate post. In keyword framework, we create methods for each and every action. We keep those methods in excel sheet and call those actions whenever required in the test scripts. The main advantage of this is reusability of code. Most of the companies use the hybrid framework. As per my knowledge, very few use keyword driven. We could take more advantage by combining multiple frameworks. Refer this – Types of frameworks
Hi Raj Kumar,
Thanks for the detailed document for each topic. Very helpful.
Welcome Rajashekar.
Hi Raj Kumar,
Thanks for the detailed document for each topic. Very helpful.
can you please keep the core java interview questions for the selenium automation testers
Thanks in advance
Hi Shivateja, Sure I will update ASAP. Also I will publish Java tutorial by end of this weekend.
Hi Raj,
Thanks for this tutorial.I am biginner to selenium and your post helped me alot.
Hi Shruti, welcome to our site. You can learn Java from here