Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: selenium data driven testing...Unable to compile this program.help me out

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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);

    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jan 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: selenium data driven testing...Unable to compile this program.help me out

    ddt

    --- Update ---

    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)
    Last edited by Norm; January 14th, 2013 at 08:28 AM. Reason: changed quote to code tags

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: selenium data driven testing...Unable to compile this program.help me out

    FileNotFoundException: D:\Book1.xls (
    The program can not find the file. Check the spelling of the name and the location.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Jan 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: selenium data driven testing...Unable to compile this program.help me out

    Quote Originally Posted by Norm View Post
    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

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: selenium data driven testing...Unable to compile this program.help me out

    unable to compile
    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.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Implement 2PC Protocol - Unable to Compile and Execute
    By The.Reaper in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 29th, 2012, 06:25 AM
  2. program won't compile, can't get data from google analytics
    By nervous in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 20th, 2012, 11:57 PM
  3. Replies: 1
    Last Post: June 9th, 2011, 08:51 AM
  4. Need Java code to be used in Selenium Script
    By anujbatta in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 25th, 2011, 10:50 AM
  5. Unable to retriving the data using WHERE condition
    By bhaskar_reddy in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: May 14th, 2010, 02:40 AM