title: Eclipse - Data Driven Framework - Error Shown
body: <p><a href="https://i.stack.imgur.com/Sptyh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Sptyh.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/1YVQ7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1YVQ7.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/hOeWo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hOeWo.png" alt="enter image description here"></a>I have written a data driven framework Java program using below 2 classes. Inthis prgram am trying to log into system by taking login ids from external excel file. </p>
  
  <ol>
  <li><p>DDF_ExcelClass - library java class to take data from external excel 
  file and will be called in SnapDealLogin_2</p></li>
  <li><p>SnapDealLogin_2 - datadrivenframework java program which is failed. In 
  this class am taking login data from external excel file using 
  DDF_ExcelClass.</p></li>
  </ol>
  
  <p>The error message shown are java.lang.RuntimeException: and 
      java.lang.ArrayIndexOutOfBoundsException: 5</p>
  
  <p>Please note if login ids are given inside the program (not taking from external excel file) then SnapDealLogin_2 works good. failing when try to 
  take login ids from excel file.
  I have tried to identify the cause of fail but could not. please help.</p>
  
  <pre class="lang-java prettyprint-override"><code>// Data Driver Framework - Excel Class stored as Library to reuse
  
  package datadrivenframework;
  import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  import org.apache.poi.xssf.usermodel.XSSFSheet;
  import java.io.File;
  import java.io.FileInputStream;
  
  public class DDF_ExcelClass{
  
  XSSFWorkbook Snap_WB;
  XSSFSheet Snap_Sheet;
  
  // NAVIGATING TO THE EXCEL FILE 
  public DDF_ExcelClass(String Path) throws Exception{
  File Snap_Excel = new File(Path);
  FileInputStream Snap_Input = new FileInputStream(Snap_Excel);
  Snap_WB = new XSSFWorkbook(Snap_Input);
  Snap_WB.close();
  }
  
  // NAVIGATING TO THE EXCEL SHEET AND GETTING THE CELL VALUE THEN RETURNING THE SAME
  public String Snap_ok(int SheetIndex, int Row, int Column){
  Snap_Sheet  = Snap_WB.getSheetAt(SheetIndex);
  String Snap_DataR = Snap_Sheet.getRow(Row).getCell(Column).getStringCellValue();
  //System.out.println("THE VALUE IN THE ROW  " + Row + "  IS  " + Snap_DataR);
  return Snap_DataR;
  }
  // FINDING THE TOTAL ROW COUNT IN THE DATA SHEET AND RETURNING THE SAME
  public int filerowcount(int SheetID){
  int rowcount = Snap_WB.getSheetAt(SheetID).getLastRowNum();
      //rowcount = rowcount+1;
  
  return rowcount;
  
  }
  }
  </code></pre>
  
  <p>This is a simple data driver framework program where data is taken from external excel file</p>
  
  <pre class="lang-java prettyprint-override"><code>package datadrivenframework;
  
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.chrome.ChromeDriver;
  import java.io.IOException;
  import java.util.concurrent.TimeUnit;
  
  import org.openqa.selenium.By;
  import org.testng.annotations.AfterMethod;
  import org.testng.annotations.Test;
  import org.testng.annotations.DataProvider;
  import datadrivenframework.DDF_ExcelClass;
  
  
  public class SnapDealLogin_2 {
  
      @Test(dataProvider = "ABN") // declaring that @ Test annotation should get value from dataProvider annotation named "ABN" to proceed further
  
      public void Snap_Login(String UserID) throws InterruptedException{
      System.setProperty("webdriver.chrome.driver",
      "C:\\Users\\hp\\workspace\\Selenium\\browser\\chromedriver.exe"); // declaring the location of Chromedriver
      WebDriver Snap = new ChromeDriver(); // initializing webdriver Snap as ChromeDriver
      Snap.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); // adding implicit wait
      Snap.get("https://www.snapdeal.com/");// entering snapdeal web  url
      Thread.sleep(3000);// adding sleep
      Snap.manage().window().maximize(); // maximizing the browser
      Thread.sleep(2000);// adding sleep
      Snap.findElement(By.xpath(".//*[@id='sdHeader']/div[4]/div[2]/div/div[3]/div[3]/div/span[1]")).click();// clicking Sign-On button
      Snap.findElement(By.xpath("//a [@href='https://www.snapdeal.com/login']")).click(); // Clicking Login button
      Snap.switchTo().frame("loginIframe"); // Switching the webdriver control to new frame "Loginframe"
      Snap.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);// adding implicit wait
      Snap.findElement(By.id("userName")).sendKeys(UserID); // entering User id
      Snap.findElement(By.id("checkUser")).click(); //clicking "Continue"button
      Snap.quit(); // closing the window
      }
  
      @DataProvider(name = "ABN") // adding annotation as DataProvider and naming it as "ABN"
          public Object [][] Snap_DP() throws Exception{
          DDF_ExcelClass DEC = new DDF_ExcelClass("C:\\Users\\hp\\Desktop\\User_Credentials.xlsx");
          int rowcount = DEC.filerowcount(0);
          Object[][] xlobject = new Object[rowcount][1];
          for(int I = 0; I&lt;=rowcount; I++){
          xlobject[I][0] = DEC.Snap_ok(0, I, 0);
          }
          return xlobject;
      }
  
  
  }
  </code></pre>