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, 2019 in Selenium by Jignesh
2,798 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, 2019 by Abha
• 27,930 points

Related Questions In Selenium

0 votes
1 answer

How can I select an option from a dropdown using Ruby Selenium Webdriver?

Hey Swasti, you can try following lines ...READ MORE

answered Aug 26, 2019 in Selenium by Anvi
• 14,110 points
927 views
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,340 points
1,181 views
0 votes
1 answer

How can I locate web elements from a web page using Selenium Webdriver?

Hey @Dushyant, Locating elements in WebDriver is ...READ MORE

answered May 28, 2019 in Selenium by Shreya
899 views
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, 2019 in Selenium by Anvi
• 14,110 points
1,040 views
0 votes
2 answers

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,510 points
3,553 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,562 views
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,890 points
2,609 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
2,890 views
0 votes
1 answer

How can we read data from an excel sheet in Selenium webdriver?

Hi Tarun, to read data from an ...READ MORE

answered May 8, 2019 in Selenium by Abha
• 27,930 points
12,064 views