Skip to content

05. XLS TestNG DataProvider

Hemanth Sridhar edited this page Mar 3, 2022 · 1 revision

XLS Excelworkbook with custom sheet name

Assuming that we have 4 columns in the

excelworkbook name workbookName.xls

and with sheet name (custom_sheet_name)

@DataProvider
public Object[][] excelSheetDataRead() throws Exception {
    ExtUtils ext = new ExcelUtils("src/test/resources/workbookName.xls");
    /*
      Using custom_sheet_name
      ExtUtils ext = new ExcelUtils("src/test/resources/workbookName.xls","custom_sheet_name");
     */
    return ext.parseData();
}
@Test(dataProvider = "excelSheetDataRead", dataProviderClass = ExtDataProvider.class)
public void loginTest2(String param1,String param2,String param3,String param4) {
  System.out.print(param1 + ",");
  System.out.print(param2 + ",");
  System.out.print(param3 + ",");
  System.out.print(param4);
  System.out.println();
}