【发布时间】:2014-05-06 13:08:24
【问题描述】:
我正在尝试从 excel 文件中读取用户名和密码,下面是我的代码,但它显示以下错误:
log4j:WARN 找不到记录器的附加程序 (org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager)。 log4j:WARN 请正确初始化log4j系统。
代码:
public static void main(String[] args) throws BiffException, IOException {
Sheet s;
WebDriver driver = new FirefoxDriver();
FileInputStream fi = new FileInputStream("E:\\myExcelWorkBook.xls");
Workbook W = Workbook.getWorkbook(fi);
s = W.getSheet(0);
for(int row = 0;row <= s.getRows();row++){
String Username = s.getCell(0,row).getContents();
System.out.println("Username" +Username);
driver.get("AppURL");
driver.findElement(By.id("txtUserName")).sendKeys(Username);
String password= s.getCell(1, row).getContents();
System.out.println("Password "+password);
driver.findElement(By.id("txtPassword")).sendKeys(password);
driver.findElement(By.id("btnLogin")).click();
}
}
请帮帮我。
【问题讨论】:
-
表你使用哪个包你能告诉我。现在我会试试
-
读取excel文件与selenium webdriver无关。分开你的代码,首先确保你可以从excel文件中读取数据到
username和'password'变量中。 -
@Faizthanx 的帮助。它现在正在工作......
-
如果您询问 log4j 警告,我怀疑这是重复的:stackoverflow.com/questions/12532339/…
-
我认为如果你按照@JpR 的建议修复 log4j,你会看到一些日志来帮助你。
标签: java excel selenium logging jxl