2014-09-23 121 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

相關問題