Forum Discussion

ashly's avatar
ashly
Occasional Contributor
4 months ago

convert absolute path to relative path

hi, 

In the tested apps in testcomplete, I have given an absolute path to open the application that I am testing. How can I use relative path instead of this path

7 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    You are providing TC, the exact location, using absolute path, to locate Vision.exe. If you were to use "relative path", how would you get to Vision.exe?

    • ashly's avatar
      ashly
      Occasional Contributor

      In different computers the path will be different... so is there any way to make this path relative?

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    You can define an environment variable that stores the absolute path followed by the executable file. You should then be able to use, for example

     

    %VisionPath%\Vision.exe

     

    Where %VisionPath% could be either

    D:\6.5\build\win64\vc15.0\Unicode Release
    C:\Temp
    X:\Something\Else
    • ashly's avatar
      ashly
      Occasional Contributor

      This solution of environment variables also suggest giving the path as absolute path, For our context what we need is a relative path

      i.e Instead of giving path as "C:\Testcomplete\v1.0\Testapps\vision.exe"
      is it possible to give "..\Testapps\vision,exe"

      assuming the test complete project file is in the path "C:\Testcomplete\v1.0\Project1"

      the Use case of this scenario is we can create multiple copies of the "C:\Testcomplete\v1.0" and use it for testing different versions

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    If your application doesn't depend on DLL's or it's own library files, then you can have Vision.exe within your TestComplete project folder. Try it, and see what happens.

     

    The easiest solution is to use environment variables, which doesn't involve changing your TestComplete project, but that is entirely up to you.

     

    As an example, have a look at https://stackoverflow.com/questions/1672281/how-to-set-the-environment-variables-for-java-in-windows. Regardless of what version of JDK you are using, to use the correct version you just adjust the environment variable JAVA_HOME.

    • ashly's avatar
      ashly
      Occasional Contributor

      Hi, it is not possible to copy the exe to a local folder as the application has more than 50 DLL's.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    The only solution I can think of, is using environment variable, as suggested.

     

    There's no harm in trying what you suggested,

     

    "i.e Instead of giving path as "C:\Testcomplete\v1.0\Testapps\vision.exe"
    is it possible to give "..\Testapps\vision,exe"

    assuming the test complete project file is in the path "C:\Testcomplete\v1.0\Project1"".