i Tried to get data from excel in java. if i execute it as normal java program i am getting data from excel and it is getting printed in console.But when i put it my Robotium test project, i am getting null pointer exception(file or directory not found).
public void testCanOpenSettings() throws IOException, Exception {
loginvalid();
}
public void Eula() {
if(solo.searchText("Accept"))
{
System.out.println(" Eula accept");
solo.clickLongOnText("Accept");
}
}
public void loginvalid() throws IOException {
String username;
String password;
solo.sendKey(Solo.MENU);
solo.sleep(3000);
solo.clickLongOnText("Sign In");
solo.sleep(3000);
//solo.clearEditText(0);
username = Readexcel(0,0);
password = Readexcel(0,1);
solo.enterText(0,username);
solo.enterText(1, password);
solo.clickOnCheckBox(0);
solo.clickLongOnText("Sign In");
}
public static String Readexcel(int row,int col) throws IOException {
String filename = "C://Documents//Robo//robo1.xls";
String s = "";
try
{
FileInputStream fis = new FileInputStream(filename);
HSSFWorkbook myWorkBook = new HSSFWorkbook(fis);
HSSFSheet mySheet = myWorkBook.getSheetAt(0);
HSSFRow row1 = mySheet.getRow(row);
HSSFCell cell1 = row1.getCell(col);
s = cell1.getRichStringCellValue().getString();
System.out.println("Cell 1 : "+s);
Log.d("cell value",s );
System.out.println(s);
return s;
}
catch (IOException e) {
e.printStackTrace();strong text
return null;
}
}
}