Skip to content

04. XLSX TestNG Data Provider

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

XLSX TestNG Data Provider

Assuming that we have 4 columns in the

excelworkbook name workbookName.xlsx

and with sheet name (custom_sheet_name)

@DataProvider
public Object[][] excelSheetDataRead() throws Exception {
    ExtUtils ext = new ExcelUtils("src/test/resources/workbookName.xlsx");
    /*
      Using custom_sheet_name
      ExtUtils ext = new ExcelUtils("src/test/resources/workbookName.xlsx","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();
}