Upload file based on relative path

yiannisyiannis Posts: 8

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

  • jakubiakjakubiak Posts: 664 admin

    Use a path that is in your workspace and is relative to the location of the .tst file.

  • yiannisyiannis Posts: 8
    edited July 1

    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.txt

    If I put an absolute path, the above will work.

  • jakubiakjakubiak Posts: 664 admin

    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.

  • yiannisyiannis Posts: 8

    Done
    I worked with ScriptingContext and created a sample Javascript script to get the absolute path.
    Thanks

Sign In or Register to comment.