0

how can I resolve the issue? I am reading the data from Excel file and the output is in String.
The method "getData" with DataProvider requires Object[][] return type.

public class Utilities extends Page {

    @DataProvider(name = "readProductNumber")
    public Object[] getData(Method method) {

        ReadDataFromExcel readDataFromExcel = new ReadDataFromExcel();
        String data = readDataFromExcel.ReadCellData(1, 0);


        return data;

    }
}

Error:(17, 16) java: incompatible types: java.lang.String cannot be converted to java.lang.Object[]

3
  • Please follow the guidelines for asking a question stackoverflow.com/help/how-to-ask. Looks like you have put Zero effort to identify the problem yourself. Commented Jul 14, 2020 at 9:49
  • Nishit, I tried to resolve that myself, however with no success, that's why I wrote the question. I think this website is meant for that. Commented Jul 14, 2020 at 9:52
  • Yes, the website is meant for that, but we expect to know from you what all you tried. Especially, in this case, the error you mentioned explains clearly what the problem is. While we are here to help you, we can't do your job for you. We expect to see the effort that you have put in. Commented Jul 14, 2020 at 10:02

1 Answer 1

4

String is an Object, but your method needs to return an Object array.

You could put it into an array like so: return new Object[]{data}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.