I want to upload a file with selenium webdriver. The file is in resources folder of my project, how can i do ?
Asked
Active
Viewed 1,885 times
-4
-
1could u please put some code snippet? – Deepak Tripathi Jun 22 '16 at 09:00
-
Hello and welcome to StackOverflow. Please take some time to read the help page, especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). And more importantly, please read [the Stack Overflow question checklist](http://meta.stackexchange.com/q/156810/204922). You might also want to learn about [Minimal, Complete, and Verifiable Examples](http://stackoverflow.com/help/mcve). – A_Di-Matteo Jun 22 '16 at 09:04
1 Answers
-1
easy way is simple case of just finding the element and typing the absolute path of the document into it.
HTML code should look similar to this :
<input type="file" name="datafile">
Syntax:
//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");

Deepak Tripathi
- 600
- 2
- 4
- 22