Thanks for the answer, I don't think I'm using it ... I'm just trying my hand at it.
do you have any examples to follow?
my spartan code is this
Class Dataprovider read excel file
-------------------------------------------------------
public class InputDataProvider {
@DataProvider(name = "DatiInput") //(name ="BCBEdata")
public Object[][] excelDP(ITestContext context) throws IOException {
String DataSheet=context.getCurrentXmlTest().getParameter("DataSheet");
System.out.println("Lettura dati di configurazione "+context.getCurrentXmlTest().getParameter("DataSheet"));
//We are creating an object from the excel sheet data by calling a method that reads data from the excel stored locally in our system
InputDataProvider inputDataProvider = new InputDataProvider();
Object[][] arrObj = inputDataProvider.getExcelData(System.getProperty("user.dir") + "\\config\\Pippo.xlsx"
, Pippo);
return arrObj;
}
//This method handles the excel - opens it and reads the data from the respective cells using a for-loop & returns it in the form of a string array
public String[][] getExcelData(String fileName, String sheetName){
String[][] data = null;
try
{
FileInputStream fis = new FileInputStream(fileName);
XSSFWorkbook wb = new XSSFWorkbook(fis);
XSSFSheet sh = wb.getSheet(sheetName);
XSSFRow row = sh.getRow(0);
int noOfRows = sh.getPhysicalNumberOfRows();
int noOfCols = row.getLastCellNum();
Cell cell;
data = new String[noOfRows-1][noOfCols];
for(int i =1; i<noOfRows;i++){
for(int j=0;j<noOfCols;j++){
row = sh.getRow(i);
cell= row.getCell(j);
DataFormatter formatter = new DataFormatter();
String cellLettura = formatter.formatCellValue(cell);
// String cellLettura = String.valueOf(cell.getStringCellValue());
data[i-1][j] = cellLettura;
}
}
}
catch (Exception e) {
System.out.println("The exception is: " +e.getMessage());
}
return data;
}
}
-------------------------------------------------------
class test @factory e multi @test
public class RicercaBenestareBCBEDataProvider extends BaseTest {
public String BCBE;
public String TEST1;
public String TEST2;
protected static ConfigurationProperties config;
protected static By versione = By.xpath("//div[@class='container-fluid']//strong[1]");
public static long IDSessione;
// public RicercaBenestareBCBEDataProvider(String BCBE,String TEST1) {
// this.BCBE=BCBE;
// this.TEST1=TEST1;
// }
public RicercaBenestareBCBEDataProvider(String BCBE,String TEST1,String TEST2) {
this.BCBE=BCBE;
this.TEST1=TEST1;
this.TEST2=TEST2;
}
@Factory(dataProvider = "DatiInput",dataProviderClass =
InputDataProvider.class)
static Object [] factorymethod (String BCBE,String TEST1,String TEST2)
{
BCBE=BCBE;
TEST1=TEST1;
TEST2=TEST2;
return new Object[] { new RicercaBenestareBCBEDataProvider(BCBE,TEST1,TEST2) } ;
}
@Test (groups = "windows.checkintest", description = "BenestareBCBE")
public void TestLetturaDati(ITestContext context) throws InterruptedException {
System.out.println(BCBE+" "+TEST1+" "+TEST2);
System.out.println(BrowserName);
System.out.println(System.currentTimeMillis());
IDSessione = System.currentTimeMillis();
System.out.println(IDSessione);
context.setAttribute("IdSessioneTest",IDSessione);
}
@Test (groups = "windows.checkintest" ,dependsOnMethods = "TestLetturaDati", description = "BenestareBCBE")
public void TestFindBCBE() throws InterruptedException {
System.out.println(IDSessione);
SeleniumBCBE = new SeleniumBCBE(driver);
config = new ConfigurationProperties();
SeleniumBCBE.ClickBenestare();
SeleniumBCBE.ClickRicercaBenestare();
//SeleniumBCBE.ClickCampoCodiceBCBE (config.getData("codiceBCBE2"));
SeleniumBCBE.ClickCampoCodiceBCBE(BCBE);
SeleniumBCBE.ClickSubmit();
}
@Test (groups = "windows.checkintest",dependsOnMethods = "TestFindBCBE", description = "VerificaBenestareBCBE")
public void TestVerifySearch () {
System.out.println(IDSessione);
SeleniumBCBERicercaBenestarePage = new SeleniumBCBERicercaBenestarePage(driver);
Assert.assertTrue(SeleniumBCBERicercaBenestarePage.VerificaTabella()>=1);
Assert.assertTrue(SeleniumBCBERicercaBenestarePage.VerificaNumeroBCBE(BCBE));
}
}
Thanks