I am trying to read Data from Excel file and input data to my web application but its not working.
Please have a look at my code.This is the class created for excel
I used Apache POI
Excel class
package ReadExcel;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class Excel_Data {
HSSFWorkbook wb;
HSSFSheet sheet1;
public Excel_Data(String fileName,String sheetName) throws Exception {
File src= new File("E:\\Jino_testing\\Git_Hub\\Zmarta_se\\resources\\Zmarta.xls");
FileInputStream fis = new FileInputStream(src);
HSSFWorkbook wb = new HSSFWorkbook(fis);
}
public String getData( int sheetNumber, int row,int column) {
HSSFSheet sheet1 =wb.getSheetAt(0);
String data =sheet1.getRow(row).getCell(column).getStringCellValue();
return data;
}
}
This is my Test class which I am running
public void ApplyLoan() throws Exception {
//Reading Excel
Excel_Data read = new Excel_Data("Zmarta.xls","Co-Applicant" );
Thread.sleep(3000);
driver.findElement(apply).click();
driver.findElement(loan).click();
Thread.sleep(7000);
driver.findElement(amount).sendKeys(read.getData(0,1,1));
Thread.sleep(3000);
new Select (driver.findElement(years)).selectByVisibleText("14 år");
}