2015-10-16 121 views
0

我在UBUNTU系统中使用Selenium驱动程序..现在我想从我的系统上传文件..我从Excel表中取值..我正在使用dataprovider ..i ..在Excel中给出的路径..当我运行脚本它不上载文件..它打开窗口..但不选择文件..下面是代码,我想..我也附上应用程序代码..请帮助我..使用Excel在webdriver中上传文件

@Test(dataProvider="ITRequest") 
public void testMultipleITRequests(String category, String summary,   
String Description, String Filename1, String comment) 
{ 
driver.findElement(By.id("new_it")).click(); 
Select se=new Select(driver.findElement(By.id("category"))); 
se.selectByVisibleText(category); 
driver.findElement(bysummary).sendKeys(summary); 
driver.findElement(byDescription).sendKeys(Description); 
driver.findElement(By.id("Filename1")).click(); 
driver.findElement(By.id("Filename1")).sendKeys("Filename1"); 
driver.findElement(bycomment).sendKeys(comment); 
driver.findElement(bybtnSubmit).click(); 
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); 
driver.findElement(By.xpath("//html/body/div[1]/div[3]/div/div/div[3]/but  ton")).click(); 
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); 
+0

也许你有一个网站截图或链接? –

+1

可能的重复[如何在Java中使用Selenium webdriver上传文件](http://stackoverflow.com/questions/16896685/how-to-upload-files-using-selenium-webdriver-in-java) – JeffC

+0

哪些浏览器是你使用..在FF中有相同的问题,但在铬工作。升级FF解决了问题。 – Sighil

回答

0

您正在尝试上传文件以错误的方式。 您必须对文件上传输入标签使用sendkeys命令。

driver.findElement(By. Id("Filename1")) .sendKeys("/path/to/the/file")

相关问题