How can I read numeric data from an Excel sheet using Selenium Webdriver?

0 votes
How can I read numeric data from an Excel sheet using Selenium Webdriver?
Jul 17 in Selenium by Jignesh
387 views

1 answer to this question.

0 votes

Hey Jignesh, for reading numeric data from an excel sheet you need to use Apache POI. Apache POI provides getNumericCellValue() method which return the numeric value of excel sheet cells. Following example shows how to do that:

import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import org.testng.annotations.Test;


public class ReadExcel 

{

@Test
public void testReadCellNumeric() throws Throwable, IOException
{
         String path=System.getProperty("user.dir"); 

         // load workbook
XSSFWorkbook wb=new XSSFWorkbook(new FileInputStream(new File(path+"/TestData/AppTestData.xlsx")));

        // read numeric data 
int data= (int)wb.getSheetAt(0).getRow(0).getCell(1).getNumericCellValue();

        // print on console
System.out.println("Data from Excel is >>> "+data);

}
}
answered Jul 17 by Abha
• 27,180 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

How can I download the *.jar file from http:// seleniumhq.org using selenium WebDriver?

For Selenium Standalone Server use this: profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/java-archive"); and ...READ MORE

answered Apr 9, 2018 in Selenium by Martin
• 4,220 points
608 views
0 votes
1 answer
0 votes
1 answer

How can I store data into a cookie using Selenium Webdriver?

Hey Abhilasha, we can load a website ...READ MORE

answered Jun 19 in Selenium by Anvi
• 13,960 points
95 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
973 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,130 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
870 views
0 votes
1 answer