Got some problem here, could you please navigate me how to resolve it?
So here is my code to read Excel
import java.io.IOException;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ReadExcel {
public String unicode;
public String[][] readExcel() throws IOException {
XSSFWorkbook excelObject = new XSSFWorkbook("./data/unicode1.xlsx");
XSSFSheet excelSheet = excelObject.getSheet("Sheet1");
int rows = excelSheet.getLastRowNum();
int columns = excelSheet.getRow(0).getLastCellNum();
String[][] data = new String [rows][columns];
for (int i = 1; i <= rows; i++) {
XSSFRow row = excelSheet.getRow(i);
for (int j = 0; j < columns; j++) {
XSSFCell cell = row.getCell(j);
String cellValue = cell.getStringCellValue();
data[i-1][j] = cellValue;
}
}
return data;
}
}
My code for the test case
import java.io.IOException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import com.github.javafaker.Faker;
import commonFeatures.CommonThings;
import commonFeatures.ReadExcel;
public class SignUpWithUnicode extends CommonThings{
Faker faker = new Faker();
@Test(dataProvider = "fetchData")
public void signUpWithUnicode(String unicode) throws InterruptedException {
invokeBrowser("chrome", "https://master.signup");
type(locateEle("xpath","//input[@id='first_name-id']"),faker.name().firstName());
type(locateEle("xpath","//input[@id='last_name-id']"),faker.name().lastName());
type(locateEle("xpath","//input[@id='last_name-id']"),faker.name().lastName());
type(locateEle("xpath","//input[@id='client_user_email-id']"),faker.internet().emailAddress());
type(locateEle("xpath", "//input[@id='password-id']"), "12345");
type(locateEle("xpath", "//input[@id='degree-id']"), unicode);
click(locateEle("xpath", "//span[contains(text(),'SUBMIT')]"));
closeBrowser();
}
@DataProvider (name = "fetchData")
public String[][] getData() throws IOException {
ReadExcel excel = new ReadExcel();
return excel.readExcel();
}
}
And here is the error
[RemoteTestNG] detected TestNG version 7.0.0
FAILED: signUpWithUnicode
org.testng.internal.reflect.MethodMatcherException:
[public void testCases.SignUpWithUnicode.signUpWithUnicode(java.lang.String) throws java.lang.InterruptedException] has no parameters defined but was found to be using a data provider (either explicitly specified or inherited from class level annotation).
Data provider mismatch
I am using Unicode characters in my Excel sheet, so I tried to use Object
instead of String
, but still having this error. Then I tried to use the strings in my Excel just to find the error and still no success.