I am getting this error when executing Testng in selenium

914 views Asked by At

Data Provider public java.lang.Object[] as.get() must return either Object[][] or Iterator<Object>[], not class java.lang.Object;

1

There are 1 answers

0
juherr On

As the documentation says:

The Data Provider method can return one of the following two types:

  • An array of array of objects (Object[][]) where the first dimension's size is the number of times the test method will be invoked and the second dimension size contains an array of objects that must be compatible with the parameter types of the test method. This is the cast illustrated by the example above.

  • An Iterator<Object[]>. The only difference with Object[][] is that an Iterator lets you create your test data lazily. TestNG will invoke the iterator and then the test method with the parameters returned by this iterator one by one. This is particularly useful if you have a lot of parameter sets to pass to the method and you don't want to create all of them upfront.

So, I suppose you current data provider method is returning Object instead of one of the 2 supported types.