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

but when I share my automation tests the path of the other tester is

I tried to put as relative path
but this didn't work.

Any suggestions?


  • jakubiakjakubiak Posts: 706 admin

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

  • yiannisyiannis Posts: 8
    edited July 2020

    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

    Additional Details:
    invalid argument: File not found : ../documents/myfile.txt

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

  • jakubiakjakubiak Posts: 706 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

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

  • benken_parasoftbenken_parasoft Posts: 957 ✭✭✭

    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)

Sign In or Register to comment.