In the last post, we have already discussed how to read excel data using POIbut we have missed one important point which can become the blocker for you. We can read numeric data from Excel using apache poi for Selenium webdriver.
This video will talk about How to read excel file in Selenium using Apache POI. In Automation, we have to take data from an external source like excel file. Apr 16, 2018 Apache POI helps Java/Java related technologies to read and write Excel files on different platforms. Using apache poi, we can do read and write operation of both xls and xlsx file formats. Apache poi is an open-source tool developed by apache. Apache POI will be helpful to modify the large content of data. Sep 21, 2018 We are working on the marathon of tutorials to maintain parameterization efficiently. There is a very wide scope of data science and data analytics these days. Experts basically look for test data management in any Automation framework, so it’s our responsibility to efficiently maintain the test data. Reading Specific value from excel using Apache POI in Selenium WebDriver Ankur Jain 0 Comment AutomationFramework ExcelFile Utility As we all are aware of reading and writing data from excel file is one of the most important aspects that we need to take care while designing our automation testing framework especially while using a data-driven.
The Apache POI in Selenium is a widely used API for selenium data driven testing. It is a POI library written in Java that gives users an API for manipulating Microsoft documents like.xls and.xlsx. Users can easily create, modify and read/write into excel files. POI stands for “Poor Obfuscation Implementation.”.
Our test data contains numeric data, string data, and sometimes combination as well which is totally dynamic in nature. so we need to create such library which will take care of dynamic data.
Read numeric data from Excel using apache poi
Poi For Xlsx Read In Selenium For Mac Windows 10
Program to read numeric data from Excel using apache poi
2 4 6 8 10 12 14 16 18 20 22 24 26 28 | import java.io.FileInputStream; import org.apache.poi.xssf.usermodel.XSSFWorkbook; { @Test { // return the path of local path of project XSSFWorkbook wb=newXSSFWorkbook(newFileInputStream(newFile(path+'/TestData/AppTestData.xlsx'))); // read numeric data intdata=(int)wb.getSheetAt(0).getRow(0).getCell(1).getNumericCellValue(); // print on console System.out.println('Data from Excel is >>> '+data); } |
Poi For Xlsx Read In Selenium For Mac Catalina
Few observations while reading the different set of Data
- You need to make sure which kind of data you want to read.
- To read String value you can call getStringCellValue() method
- To read Numeric value you can call getNumericCellValue() which will return double value which we can typecast into int and then we can use in our test data.
You can check below screenshot which will explain what are the different type of methods which can help us to read data.
While implementing Data-driven frameworkyou have to make sure that data which is coming from excel should be used in script effectively.
The Same concept will be applied while writing to excel as well. While passing the data to excel you can call respective methods.
Let’s see the below screenshot for more details.
In above screenshot,you can see it will ask you to pass the specific data to write in excel.
Hope above post will help you to read the numeric data from excel.
If you have any doubt then let me know in comment section.