selenium data driven testing...Unable to compile this program.help me out
package first;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
public class example {
public static String val;
public static String getval(String stname,int rownum,int cellnum) throws Exception, FileNotFoundException, IOException
{
Workbook wb=WorkbookFactory.create(new FileInputStream("C:Book1.xls"));
int st=wb.getSheetIndex(stname);
Sheet s=wb.getSheetAt(st);
Row r=s.getRow(rownum);
Cell c=r.getCell(cellnum);
val=c.getStringCellValue();
return val;
}
public static void main(String[] args) throws FileNotFoundException, IOException, Exception {
String s=getval("sheet1",3,1);
System.out.println(s);
}
}
Re: selenium data driven testing...Unable to compile this program.help me out
Please explain the problem. If you get error messages, copy the full text and pasted it here.
Please edit your post and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
Re: selenium data driven testing...Unable to compile this program.help me out
ddt
--- Update ---
Code :
package first;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
public class example {
public static String val;
public static String getval(String stname,int rownum,int cellnum) throws Exception, FileNotFoundException, IOException
{
Workbook wb=WorkbookFactory.create(new FileInputStream("D:\\Book1.xls"));
int st=wb.getSheetIndex(stname);
Sheet s=wb.getSheetAt(st);
Row r=s.getRow(rownum);
Cell c=r.getCell(cellnum);
val=c.getStringCellValue();
return val;
}
public static void main(String[] args) throws FileNotFoundException, IOException, Exception {
String s=getval("sheet1",3,1);
System.out.println(s);
}
}
getting the following error
Exception in thread "main" java.io.FileNotFoundException: D:\Book1.xls (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at first.example.getval(example.java:17)
at first.example.main(example.java:28)
Re: selenium data driven testing...Unable to compile this program.help me out
Quote:
FileNotFoundException: D:\Book1.xls (
The program can not find the file. Check the spelling of the name and the location.
Re: selenium data driven testing...Unable to compile this program.help me out
Quote:
Originally Posted by
Norm
The program can not find the file. Check the spelling of the name and the location.
checked it many times but still unable to compile
Re: selenium data driven testing...Unable to compile this program.help me out
What compiler error are you getting?
The posted error is a runtime error because the program can not find the file named in the error message.