I'm doing some automated testing with selenium webdriver in eclipse. I need to attach actual files and then send them. The problem is these files can't be on my local drive since the completed tests are uploaded to a server so that they can be ran continuously and the connection to my local files will be lost causing the tests to fail. Is there a way to include these test files in the eclipse project in some folder then use the tests to attach or upload these files?
-
If the files are under source control, then both your local environment and also the remote CI server will both have access to the files.djangofan– djangofan2013-10-28 20:36:22 +00:00Commented Oct 28, 2013 at 20:36
-
the files will be in the project folder which will be uploaded and then used by the server and downloaded by other users, the root folder for the other users won't be the same so I'm guess the idea is to use some sort of relative path like ../../src/test/text.txt?vslat– vslat2013-10-29 14:52:40 +00:00Commented Oct 29, 2013 at 14:52
-
Yes, if you use Maven or Gradle, then the use of relative paths to the project root are the usual convention.djangofan– djangofan2013-10-29 16:50:26 +00:00Commented Oct 29, 2013 at 16:50
Add a comment
|
2 Answers
Yes, you can store the files in the resources or res folder of your eclipse project and then reference these using relative paths. In that case you will be making these files part of your repository.
Another way is to leave all the files in a shared folder and point to these from the test cases, so in that case you don't need to commit the files to the repository, we used to make that with big files.
1 Comment
gihanchanuka
You can create a "res" folder inside the src folder. Then add your attachments there. You can use following code to upload the content
String filePath = System.getProperty("user.dir") + "/src/res/test.pdf; driver.findElement(By.id("upload1")).sendKeys(filePath);