У меня проблема ниже:
org.testng.internal.reflect.MethodMatcherException:
Несоответствие поставщика данных
Метод: itemdetailsadd ([Параметр {index = 0, type = java.lang.String, Объявленные Аннотации = []}])
Аргументы: [(java.lang.String) Test23, (java.lang.String) [BLANK], (java.lang.String) [BLANK], (java.lang.String) [BLANK], (java.lang. String) [BLANK], (java.lang.String) [BLANK], null, (java.lang.String) [BLANK], (java.lang.String) [BLANK], (java.lang.String) [BLANK ],ноль ноль]
в org.testng.internal.reflect.DataProviderMethodMatcher.getConformingArguments (DataProviderMethodMatcher.java:45)
at org.testng.internal.Parameters.injectParameters (Parameters.java:796)
в org.testng.internal.Invoker.invokeTestMethods (Invoker.java:982)
в org.testng.internal.TestMethodWorker.invokeTestMethods (TestMethodWorker.java:125)
в org.testng.internal.TestMethodWorker.run (TestMethodWorker.java:109)
в org.testng.TestRunner.privateRun (TestRunner.java:648)
в org.testng.TestRunner.run (TestRunner.java:505)
в org.testng.SuiteRunner.runTest (SuiteRunner.java:455)
на org.testng.SuiteRunner.runSequentially (SuiteRunner.java:450)
в org.testng.SuiteRunner.privateRun (SuiteRunner.java:415)
в org.testng.SuiteRunner.run (SuiteRunner.java:364)
на org.testng.SuiteRunnerWorker.runSuite (SuiteRunnerWorker.java:52)
на org.testng.SuiteRunnerWorker.run (SuiteRunnerWorker.java:84)
на org.testng.TestNG.runSuitesSequentially (TestNG.java:1208)
в org.testng.TestNG.runSuitesLocally (TestNG.java:1137)
на org.testng.TestNG.runSuites (TestNG.java:1049)
на org.testng.TestNG.run (TestNG.java:1017)
на org.testng.remote.AbstractRemoteTestNG.run (AbstractRemoteTestNG.java:114)
в org.testng.remote.RemoteTestNG.initAndRun (RemoteTestNG.java:251)
atg.testng.remote.RemoteTestNG.main (RemoteTestNG.java:77)
Мой код:
@Test(dataProvider="excelread")
public void itemdetailsadd(String service) throws InterruptedException {
d.findElement(By.linkText("Product/service item details")).click();
d.findElement(By.linkText("Add new item")).click();
d.findElement(By.xpath("//*[@id='itemName']")).sendKeys(service);
d.findElement(By.xpath("//*[@id='save']")).click();
}
@DataProvider(name="excelread")
public Object[][] readexcel() throws IOException
{
Object[][] value= null;
File src = new File("D:\\Selenium jars\\Client excel\\Book1.xlsx");
FileInputStream fis = new FileInputStream(src);
XSSFWorkbook wb = new XSSFWorkbook(fis);
XSSFSheet sheet1 = wb.getSheet("Sheet1");
int rows = sheet1.getPhysicalNumberOfRows();
int cells = sheet1.getRow(0).getPhysicalNumberOfCells();
value = new Object [rows][cells];
for (int i=0;i<rows;i++) {
Row row = sheet1.getRow(i);
if (row!=null) {
for (int j=0;j<cells;j++) {
Cell c = row.getCell(j);
if (c!=null) {
switch (c.getCellType()) {
case XSSFCell.CELL_TYPE_NUMERIC:
value [i][j] = "" +c.getNumericCellValue();
System.out.print(value[i][j] +"\t");
break;
case XSSFCell.CELL_TYPE_STRING:
value [i][j]="" +c.getStringCellValue();
System.out.print(value[i][j] +"\t");
break;
case XSSFCell.CELL_TYPE_BLANK:
value[i][j] = "[BLANK]";
break;
default:
}
}
}
System.out.println();
}
}
return value;
}
}
Данные Excel. Содержат как строковые, числовые, так и нулевые значения.
Я ожидаю, что мой тестовый пример будет передавать данные вместе с нулевыми значениями в Excel при тестировании на основе данных. Но на самом деле это бросает исключение
org.testng.internal.reflect.MethodMatcherException: несоответствие поставщика данных