I want to upload a file with selenium webdriver. The file is in resources folder of my project, how can i do ?
-
1could u please put some code snippet?Deepak Tripathi– Deepak Tripathi2016-06-22 09:00:28 +00:00Commented Jun 22, 2016 at 9: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?" and "What types of questions should I avoid asking?". And more importantly, please read the Stack Overflow question checklist. You might also want to learn about Minimal, Complete, and Verifiable Examples.A_Di-Matteo– A_Di-Matteo2016-06-22 09:04:09 +00:00Commented Jun 22, 2016 at 9:04
Add a comment
|
1 Answer
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");
1 Comment
ibtissam
i'm not using '<input>' in my HTML code '<a class="tft-btn ng-binding" ng-bind="config.messages.buttonUploadTitle" ng-click="executeUploadAction()" href="">Télécharger votre modèle</a>'