As I'm new to selenium, I'm trying to read data from excel sheet, format is .xlsx... The issue is I'm unable to pass the uName and pWord values here. I'm using Eclipse ide(Galileo), jdk 1.7..Using POI libraries from Apache.
Here below is the coding, please suggest me. Thanks much in anticipate.
public class TestDataExcl {
/**
* @param args
* @throws Throwable
* @throws Exception
*/
public static void main(String[] args) throws Exception {
TestDataExcl tDataObj = new TestDataExcl();
ArrayList<String> uName = autoInputFromList(0);//Ive tried as ArrayList uName = autoInputFromList(0)..
ArrayList<String> pWord = autoInputFromList(1);
WebDriver driver = new FirefoxDriver();
driver.get("https://www.facebook.com/");
driver.findElement(By.id("email")).sendKeys(uName);//Error as:The method sendKeys(CharSequence...) in the type WebElement is not applicable for the arguments (ArrayList<String>)
driver.findElement(By.id("pass")).sendKeys(pWord);//Same as the abover error, it is not recognizing uName, pWord..
//tDataObj.autoInputFromList(0);
}
//-------------------------------Reading Data From Excel File-----------------------------//
public static ArrayList<String> autoInputFromList(int colNo) throws Exception{
String filePath = "D:\\firstFile.xlsx";
FileInputStream fisObj = new FileInputStream(filePath);
XSSFWorkbook wbObj = new XSSFWorkbook(fisObj);
XSSFSheet shObj = wbObj.getSheet("Sheet1");
//Sheet shObj = wbObj.getSheetAt(0);
Iterator<Row> rowIt = shObj.iterator();
//<Row> int i = 0;
ArrayList<String> list = new ArrayList<String>();
rowIt.next();
while(rowIt.hasNext()){
list.add(rowIt.next().getCell(colNo).getStringCellValue());
}System.out.println("List::"+list);
return list;
}
}