@DataProvider
 public String[][] getXlsData() throws Exception {
   String[][] data = null;
   ExcelUtils.setExcelFile(
       Constant.Path_TestData + Constant.File_TestData, Constant.File_TestappNameSheet);
   data = ExcelUtils.getXlsRowData(Constant.Total_Col_MetLifeGSSP);
   return data;
 }
  @BeforeClass
  public void setUp() throws Exception {

    // Configuring Log4j logs.
    new BaseClass();
    DOMConfigurator.configure(BaseClass.bLog);
    // Setting Excel File -- Test Data xls File
    ExcelUtils.setExcelFile(
        Constant.Path_TestData + Constant.File_TestData, Constant.File_TestappNameSheet);
    // Getting the Test Case name, as it will going to use in so many places
    // The main use is to get the TestCase row from the Test Data Excel sheet
    sTestCaseName = this.toString();
    Log.info(sTestCaseName);
    sTestCaseName = Utils.getTestCaseName(this.toString());
    Log.info(sTestCaseName);
    Log.startTestCase(sTestCaseName);
    testStep = new HelperFunction();
  }
  // This method is to write in the Excel cell, Row num and Col num are the parameters
  @SuppressWarnings("static-access")
  public static void setCellData(String Result, int RowNum, int ColNum, String path, String sheet)
      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);
      }
      // Constant variables Test Data path and Test Data file name
      FileOutputStream fileOut = new FileOutputStream(path);
      ExcelWBook.write(fileOut);
      fileOut.flush();
      fileOut.close();
      ExcelUtils.closeExcelFile();
      ExcelUtils.setExcelFile(path, sheet);
    } catch (Exception e) {
      throw (e);
    }
  }
  // Following TestNg Test case pattern, and divided a Test case in to three different part.
  // In Before Method, your code will always be the same for every other test case.
  // In other way before method is your prerequisites of your main Test Case
  @BeforeMethod
  public void beforeMethod() throws Exception {
    // Configuring Log4j logs, please see the following posts to learn about Log4j Logging
    // http://www.toolsqa.com/test-case-with-log4j/
    // http://www.toolsqa.com/log4j-logging/
    DOMConfigurator.configure("log4j.xml");

    // Getting the Test Case name, as it will going to use in so many places
    // The main use is to get the TestCase row from the Test Data Excel sheet
    sTestCaseName = this.toString();
    // From above method we get long test case name including package and class name etc.
    // The below method will refine your test case name, exactly the name use have used
    sTestCaseName = Utils.getTestCaseName(this.toString());

    // Start printing the logs and printing the Test Case name
    Log.startTestCase(sTestCaseName);

    // Setting up the Test Data Excel file using Constants variables
    // For Constant Variables please see http://www.toolsqa.com/constant-variables/
    // For setting up Excel for Data driven testing, please see
    // http://www.toolsqa.com/data-driven-testing-excel-poi/
    ExcelUtils.setExcelFile(Constant.Path_TestData + Constant.File_TestData, "Sheet1");

    // Fetching the Test Case row number from the Test Data Sheet
    // This row number will be feed to so many functions, to get the relevant data from the Test
    // Data sheet
    iTestCaseRow = ExcelUtils.getRowContains(sTestCaseName, Constant.Col_TestCaseName);

    // Launching the browser, this will take the Browser Type from Test Data Sheet
    driver = Utils.OpenBrowser(iTestCaseRow);

    // Initializing the Base Class for Selenium driver
    // Now we do need to provide the Selenium driver to any of the Page classes or Module Actions
    // Will soon write a post on Base Class
    new BaseClass(driver);
  }
  @Test(dataProvider = "getXlsData")
  public void testUserRegistration(
      String SrNo,
      String TestCaseName,
      String FirstName,
      String LastName,
      String CitizenId,
      String DOB,
      String ZipCode,
      String Email,
      String ConfirmEmail,
      String MobileNumber,
      String NeedToExecute,
      String Result,
      String Comments)
      throws Exception {

    try {

      flag = false;
      // Fatching Test Data from the Test Data file and store into the array [] object.
      Log.info("Fatching Test Data from the Test Data file and store into the array [] object.");
      rowIndex = Integer.parseInt(SrNo);
      rowData = ExcelUtils.getXlsRowData(rowIndex, Constant.Total_Col_MetLifeGSSP);
      // Checking if test case need to be executed or not
      Log.info(
          "Value of rowData[Constant.Col_MetLifeGSSP_NeedToExecute] -->"
              + rowData[Constant.Col_MetLifeGSSP_NeedToExecute]
              + "--"
              + NeedToExecute);
      System.out.println("No -->" + SrNo);
      if (NeedToExecute.equalsIgnoreCase("Yes")) {
        // Init the Webdriver with  Opening the browser and URL
        Log.info("Webdriver init and Opening the test application");
        driver = Utils.OpenBrowser(Constant.appName);
        Log.info("Webdriver initilazied and test application open");
        // Developing the Test Step into the Modules and based on the result we verify that the step
        // is pass or not.
        // TestBase.Assert() Function is used for assertion and this will stop the execution if
        // assert is fail.
        // TestBase.verifyAssert() Function is used for assertion verification but it will not stop
        // the execution and after capturing the error it continue the execution.

        // If function() return true then the execution will move to next step of the test case step
        // otherwise it fail and stop the execution.

        // Test Step 1
        Log.info("Execution Test Step -->openRegistrationLink");
        flag = testStep.openRegistrationLink(driver, rowIndex, sTestCaseName, rowData);
        Log.info("Test Step openRegistrationLink result -- >" + flag);
        TestBase.verifyTrue(flag);

        // Test Step 2
        if (flag) {
          Log.info("Execution Test Step -->registrationCustomer");
          flag = testStep.registrationCustomer(driver, rowIndex, sTestCaseName, rowData);
          Log.info("Test Step registrationCustomer result -- >" + flag);
          TestBase.verifyTrue(flag);
        }
        // Test Step 3
        if (flag) {
          Log.info("Execution Test Step -->verifyCaptcha");
          flag = testStep.verifyCaptcha(driver, rowIndex, sTestCaseName, rowData);
          Log.info("Test Step verifyCaptcha result -- >" + flag);
          TestBase.verifyTrue(flag);
        }
        // Test Step 3
        if (flag) {
          Log.info("Execution Test Step -->verifyRegistration");
          flag = testStep.verifyRegistration(driver, rowIndex, sTestCaseName, rowData);
          Log.info("Test Step verifyRegistration result -- >" + flag);
          TestBase.verifyTrue(flag);
        }

        Log.info("Final Result of the test case -->" + sTestCaseName + "-->" + flag);
        // Printing the result of the test case in the excel Result Column and TestNG report.

        if (flag) {
          ExcelUtils.setExcelFile(
              Constant.Path_TestData + Constant.File_TestData, Constant.File_TestappNameSheet);
          ExcelUtils.setCellData(
              "Pass",
              rowIndex,
              Constant.Col_MetLifeGSSP_Result,
              Constant.Path_TestData + Constant.File_TestData,
              Constant.File_TestappNameSheet);
          ExcelUtils.setCellData(
              "Test Case executed successfully.",
              rowIndex,
              Constant.Col_MetLifeGSSP_Comments,
              Constant.Path_TestData + Constant.File_TestData,
              Constant.File_TestappNameSheet);
          Reporter.log(sTestCaseName + " Test Case Pass");
        } else {
          throw new Exception("Test Case Failed because of Verification");
        }
      }
      // If Test Case need not to be executed.
      else {
        Log.info("Test Case need not to be executed");
        // Writing comment on the test data file why this case is skipped from the execution.
        ExcelUtils.setExcelFile(
            Constant.Path_TestData + Constant.File_TestData, Constant.File_TestappNameSheet);
        ExcelUtils.setCellData(
            "Skip",
            rowIndex,
            Constant.Col_MetLifeGSSP_Result,
            Constant.Path_TestData + Constant.File_TestData,
            Constant.File_TestappNameSheet);
        ExcelUtils.setCellData(
            "Need To Execute Request is selected as No",
            rowIndex,
            Constant.Col_MetLifeGSSP_Comments,
            Constant.Path_TestData + Constant.File_TestData,
            Constant.File_TestappNameSheet);
        throw new SkipException("Skiping This Test as 'Need To Execute' Request is selected as No");
      }

    } catch (SkipException e) {
      throw (e);
    }
  }