ChromeDriver文件上传示例

时间:2011-08-12 18:03:59

标签: java google-chrome webdriver selenium-webdriver

ChromeDriver开发团队表示他们已经解决了这个问题:http://code.google.com/p/selenium/issues/detail?id=1725&q=chrome%20file%20upload&colspec=ID%20Stars%20Type%20Status%20Priority%20Milestone%20Owner%20Summary

但我无法实现它。有人可以向我展示一个示例或使用ChromeDriver在Chrome上测试文件上传的解决方法吗?

2 个答案:

答案 0 :(得分:5)

driver.findElement(By.id("upload")).sendKeys("/path/to/the/file");

答案 1 :(得分:1)

我知道当没有对Alert的支持时,人们通过AutoIT完成了这项工作。也许在ChromeDriver支持警报之前解决方法?