我正在尝试存储UserID,密码和正在传递给我正在尝试使用selenium自动化到excel文件的网站的EmailID。 问题是正在生成的excel文件存储UserID两次,其他两个值没有写入excel。
我想要的是编写userID,EmailID&密码彼此相邻。
我的代码如下:
MfpCreateAccountPage createAccount =PageFactory.initElements(driver, MfpCreateAccountPage.class);
createAccount.userDetails(randomAlphaNumericvalue, randomAlphaNumericvalue.toLowerCase()+ "@gmail.com" , randomAlphaNumericvalue);
ExcelDriven.setCelldata(randomAlphaNumericvalue, 0, 0);
ExcelDriven.setCelldata(randomAlphaNumericvalue.toLowerCase()+ "@gmail.com", 0, 1);
ExcelDriven.setCelldata(randomAlphaNumericvalue, 0, 2);
以下是我将数据写入excel的代码
public static String setCelldata(String text,int rownum,int col)抛出IOException
{
wb= new HSSFWorkbook();
//sheet=wb.getSheet("script");
sheet = wb.createSheet("Script");
row=sheet.createRow(rownum);
cell=row.createCell(rownum);
cell.setCellValue(text);
cell = row.createCell(col);
cell.setCellValue(text);
cell = row.createCell(col);
cell.setCellValue(text);
String celldata1= cell.getStringCellValue();
FileOutputStream fos = null;
try{
fos = new FileOutputStream(new File("D:\\Data.xls"));
wb.write(fos);
}
catch (IOException e){
e.printStackTrace();
}
finally{
if(fos!= null){
try{
fos.flush();
fos.close();
}
catch (IOException e){
e.printStackTrace();
}
}
}
return celldata1;
}
有人能告诉我哪里出错了吗?感谢!!!