Upload file based on relative path
I want to upload a file in my e2e tests and I did manage it by using
/home/john/Documents/doc.txt
but when I share my automation tests the path of the other tester is
/home/george/Documents/doc.txt
I tried to put as relative path
~/Documents/doc.txt
but this didn't work.
Any suggestions?
Comments
-
Use a path that is in your workspace and is relative to the location of the .tst file.
0 -
I moved the file inside the workspace in a documents folder and I can see it in Navigator. Then I changed the path relative to my tst file but I got the error message
Error Message:
(Chrome 81.0) Unable to perform action due to an unexpected error. View details for more
information.Additional Details:
invalid argument: File not found : ../documents/myfile.txtIf I put an absolute path, the above will work.
0 -
Hmmm - since you are typing this into the browser and the browser doesn't understand the relative path, you have to type an absolute path. You could put the value into an environment variable, and use a different environment depending on what machine you are running on. Another option is to switch the input from "Fixed" to "Scripted" and write a simple script that uses the SOAtest API ScriptingContext.getAbsolutePathFile() that takes a relative path as argument and will resolve it relative to the directory in which the .tst file lives. See the Parasoft SOAtest Extensibility API JavaDocs for details on that API.
1 -
Done
I worked with ScriptingContext and created a sample Javascript script to get the absolute path.
Thanks0 -
For future reference, this one is helpful in cases where you need to get an absolute path from a path that is relative to the folder containing the tst file:
com.parasoft.api.ScriptingContext.getAbsolutePathFile(String filename)0