2014-09-23 87 views
1

我正在尝试使用Java上传Selenium网络驱动程序的文件。selenium webdriver上传文件

driver = new FirefoxDriver(); 
driver.get("http://favicon-generator.org/"); 
driver.manage().window().maximize(); 
wait.until(ExpectedConditions.elementToBeClickable(By.id("favicon"))); 
WebElement el = driver.findElement(By.id("favicon")); 
el.sendKeys("test.jpg"); 

我运行后,输入字段没有填充。

+0

当您单击创建Favicon按钮时,它会显示“您没有选择要上传的图片,请重试。” ? – 2014-09-23 13:08:14

+0

是的。 “您没有选择要上传的图片,请重试。” – 2014-09-23 13:16:59

+0

提供完整系统路径的图片 – 2014-09-23 13:19:44

回答

0

好的,我发现了这个问题。问题是格式化文件的绝对路径。它应该是:

el.sendKeys("c:\\Users\\Jacob\\workspace\\seleniumTest\\test.jpg"); 
+0

是的。我正要发布我的答案。很高兴你自己找到它! – 2014-09-23 13:43:23

相关问题