Maybe you can try with jxl libraries.
With Maven, that is the pom dependency:
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>
In case of read username, password, ... you can use a bean like this:
import java.io.File;
import java.io.IOException;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
/**
*
* This is a bean to easily get users data from an excel file.
*
* @author Hector Flores - hectorfb@gmail.com
*
*/
public class ExcelUserBean {
private String filepath = null;
private Sheet sheet = null;
/**
* Read an excel file with users
*
* @param filepath
* @throws IOException
*/
public ExcelUserBean(String filepath) throws IOException {
this.filepath = filepath;
// TestData td = new TestData("SignUpUsers.xls");
getDatafromXL(this.filepath);
}
/**
* Get ID counter from excel file
*
* @param row
* (0 for column title, >0 for values)
* @return
*/
public String getId(int row) {
return sheet.getCell(0, row).getContents();
}
/**
* Get email form excel file
*
* @param row
* (0 for column title, >0 for values)
* @return
*/
public String getEmail(int row) {
return sheet.getCell(1, row).getContents();
}
/**
* Get name form excel file
*
* @param row
* (0 for column title, >0 for values)
* @return
*/
public String getName(int row) {
return sheet.getCell(2, row).getContents();
}
private void getDatafromXL(String filepath) throws IOException {
File inputWorkbook = new File(filepath);
Workbook w;
try {
w = Workbook.getWorkbook(inputWorkbook);
// Get the first sheet
sheet = w.getSheet(0);
} catch (BiffException e) {
e.printStackTrace();
}
}// End parseXLTestCase
}
Now in your test cases you can fill your bean
ExcelUserBean userBean = new ExcelUserBean(FILEPATH);
//ROWS
int begin = PropertiesConfig.getUserExcelRowFrom(); <-- from
int end = PropertiesConfig.getUserExcelRowTo(); <-- to
for (int excelRow = begin; excelRow <= end; excelRow++) {
driver.findElement(By.id("signfirstname")).sendKeys(userBean.getName(excelRow));
driver.findElement(By.id("lastname")).sendKeys(userBean.getSurname(excelRow));
}
Hope it helps!