RE: Error in Data Driven Framework

Answered

Hi,
I am working on Data Driven Framework example shown in Selenium WebDriver Tutorials in  www.toolsqa.com  website. When I run Apache_POI_TC.java file, I am getting the following error:

Exception in thread “main” java.io.FileNotFoundException: C:\Users\ABK\Desktop\Sama\Eclipse\OnlineStore\src\testData (Access is denied)

Appreciate if anyone could help me out with this error.

on November 4, 2014.
Add Comment
4 Answers

The above error is fixed. I am getting a different error. As I am a beginner in Java programming and Selenium, I have difficulty in understanding the errors. Appreciate if you could help me out.

Here is the following error message:

Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject

at utility.ExcelUtils.setExcelFile(ExcelUtils.java:25)

at automationFramework.Apache_POI_TC.main(Apache_POI_TC.java:18)

Here is the code:

Apache_POI_TC.java

package automationFramework;
    import java.io.IOException;
    import java.util.concurrent.TimeUnit;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import pageObjects.*;
    import utility.ExcelUtils;
    import utility.Constant;
    import appModules.SignIn_Action;
        
    public class Apache_POI_TC {
    public static void main(String[] args) throws Exception {
        ExcelUtils.setExcelFile(Constant.Path_TestData + Constant.File_TestData,"Sheet1");
        WebDriver driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.get(Constant.URL);
        SignIn_Action.Execute(driver);
        System.out.println("Login Successful, now its the time to Log Off Buddy");
        Home_Page.User_Account(driver).click();
        Home_Page.Sign_out(driver).click();
        driver.quit();
        ExcelUtils.setCelldata("Pass", 1, 3);
        }
    }

ExcelUtils.java

package utility;
        import java.io.FileInputStream;
        import java.io.FileNotFoundException;
        import java.io.FileOutputStream;
        import java.io.IOException;
        import org.apache.poi.xssf.usermodel.XSSFCell;
        import org.apache.poi.xssf.usermodel.XSSFRow;
        import org.apache.poi.xssf.usermodel.XSSFSheet;
        import org.apache.poi.xssf.usermodel.XSSFWorkbook;
    public class ExcelUtils {
        private static XSSFSheet ExcelWSheet;
        private static XSSFWorkbook ExcelWBook;
        private static XSSFCell Cell;
        private static XSSFRow Row;
    public static void setExcelFile(String Path, String SheetName) throws Exception{
        try{
            FileInputStream ExcelFile = new FileInputStream(Path);
            ExcelWBook = new XSSFWorkbook(ExcelFile);
            ExcelWSheet = ExcelWBook.getSheet(SheetName);
        } catch(Exception e){
            throw(e);
            }
        }
        
    public static String getCellData(int RowNum, int ColNum){
    try{
        Cell = ExcelWSheet.getRow(RowNum).getCell(ColNum);
        String CellData = Cell.getStringCellValue();
        return CellData;
    }catch(Exception e){
        return"";
        }
    }
    
    public static void setCelldata(String Result, int RowNum, int ColNum) throws Exception{
        try{
            Row = ExcelWSheet.getRow(RowNum);
            Cell = Row.getCell(ColNum, Row.RETURN_BLANK_AS_NULL);
            if(Cell == null){
                Cell = Row.createCell(ColNum);
                Cell.setCellValue(Result);
            }else{
                Cell.setCellValue(Result);
                }
            FileOutputStream fileOut = new FileOutputStream(Constant.Path_TestData + Constant.File_TestData);
            ExcelWBook.write(fileOut);
            fileOut.flush();
            fileOut.close();
        }catch(Exception e){
            throw(e);
            }
        }
    }
Train Answered on November 4, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.