Forum Discussion

ashly's avatar
ashly
Contributor
9 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

9 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
      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
      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
      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"". 

  • hi, I have a question. Since I couldn't find where to ask a new question I am asking here.

    In TestComplete keyword test I am facing an issue on opening the csv file from a path in the C folder. This was working very well earlier but now an error comes as below. Could you please help me with this. The csv file remains in the same folder itself and I haven't changed its path.

    given below is the path to the csv file

    earlier it was working well without errors as below

     

    • rraghvani's avatar
      rraghvani
      Champion Level 3

      Looking at the error message, your automation is trying to select "CSV Files" from the drop down combo box, and it's not able to find the item. I suggest you look at this first, and ensure that correct properties are given for the UI object, so that TestComplete can search for the UI object you are referring to.

       

      You start a new post via "Start a Discussion"