Forum Discussion

Uwe_Raabe's avatar
Uwe_Raabe
Occasional Contributor
16 years ago

Using path variables for Tested Apps

Is it possible to use path variables for tested apps?



Background: My complete project is located under one folder, one of it is the folder with the testcomplete suites and projects. While TestComplete takes care of relative path names in respect to it's own folder, it doesn't do this for the pathes to the tested apps, which are in a sibling folder. Now when I move all files to another folder the pathes to the tested apps still point to the old folders.



I tried to use a path variable to handle this, but I'm unsure how to do that or if it possible at all.

3 Replies

  • matt's avatar
    matt
    Occasional Contributor
    When you say path variable, do you mean the Windows environment variable PATH? Or do you mean the column in the Tested App panel called "File Path"?



    Either way I can tell you what we do. Our AUT is in the Windows PATH, so it is possible to run it without specify a fully qualified path to the EXE. We add the File Name to the TestedApp and leave the File Path value empty. It does not matter where our AUT is installed; the TestApp can be started.




    If you need to specify the File Path value and your TestedApp might not always be in the same location, I am fairly sure you can update the File Path value from script code at runtime.

  • We use the same scripts for different applications.  We get around TestedApps pathing by using the following routines that add and delete apps from the TestedApps when we need them.



    Sub AddTestedApp 

    'This subroutine adds the application under test to the tested apps list

     Project.Variables.TestAppIndex = TestedApps.Add(Project.Variables.ftAppInstall & Project.Variables.Product & ".exe")

    End Sub 'AddTestedApp


    Sub DelTestedApp  

    'This subroutine deletes the application under test from the tested apps list

     index = TestedApps.Count - 1

     Do Until index = -1

      result = TestedApps.Delete(index)

      If result = true Then

       Call log.event(Project.Variables.ftAppInstall & Project.Variables.Product & ".exe was removed from TestedApps.")

      Else

       Call DisplayMessage(Project.Variables.ftAppInstall & Project.Variables.Product & ".exe was not removed from TestedApps.", "warning")

      End If

      index = index - 1

     Loop

    End Sub 'DelTestedApp



    I hope this helps.....


  • It looks like you need to modify (at runtime) the Path property of your TestedApp object.



    I did it (in TestComplete v9.31) something like this:



        var folderPath = aqFileSystem.GetFileFolder(myExecutablePath);

        var fileName = aqFileSystem.GetFileName(myExecutablePath);

        if (fileName != TestedApps.MyExecutable.FileName)

        {

          Log.Error("The executable's name needs to be " + TestedApps.MyExecutable.FileName);

          throw "error, dude"; // don't know if this is valid syntax... either way, something fails =)

        }

        TestedApps.MyExecutable.Path = folderPath;