我想上传一个带有selenium webdriver的文件。该文件位于我项目的资源文件夹中,我该怎么办?
答案 0 :(得分:0)
简单的方法就是找到元素并在其中键入文档的绝对路径。
HTML代码应该与此类似:
<input type="file" name="datafile">
语法:
//Find the element of upload button and send the path
WebElement element= driver.findElement(By.name("datafile"));
element.sendKeys("C:\Users\Easy\Desktop\testfile.txt");