Forum Discussion

marinb's avatar
marinb
Contributor
7 years ago
Solved

Logical paths in tcScript file

Currently we have various teams using the same TestComplete script unit collection. We would like to have all those projects point to the same script files, but the location a project can vary per test system. This causes problems because the path references in the tcScript file always seem to be logical.

 

Example: " <data path="..\..\..\..\..\ezFrame\Script\ezElement.js" /> "

 

Is it possible to have hard paths? If I add an existing script unit to my project, I want it to be saved as a full path (c:\lib\scriptunit.js) and not be a logical reference (..\..\..\..\..\lib\scriptunit.js)

  • marinb's avatar
    marinb
    7 years ago

    I solved it by hacking editing the tcScript file and replacing all the relative folders with hardcoded versions.

     

    Using relative folders do not work if I want to move the project to another location. We develop on a pc where the project is located on the C-drive. Our build-environment drops the project on D:

     

    Our shared script units are on C: . Poof, can't find the script units anymore because the references are logical.

     

    Same with the log directory. If I check the log directory in current project properties, it literally reads 'C:\Temp\Log' , but in the test environment, it writes the log to D:\Temp\Log because in secret, in the .mds file the log dir is specified as '\Temp\Log'.

     

    I think that the log directory should read what's specified in the .mds file, not do a smart conversion because your project happens to be on the C-drive. This is just confusing.

     

    Some kind of option 'use logical paths' would be a nice to have.

5 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    I'm not sure if what your asking is possible.  But if each workstation has the directory "C:\lib\", you shouldn't run into any problems.  So long as you preserve the directory structure from machine to machine, the relative pathing should continue to work fine.

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      Hi,

       

      I would agree with Robert.

      All paths in the project configuration files are relative the project file folder (the folder where the .mds file is).

      And all paths in the project suite configuration files are relative the project suite file folder (the folder where the .pjs file is).

      So everything should work as long as you preserve the folders structure.

      • marinb's avatar
        marinb
        Contributor

        I solved it by hacking editing the tcScript file and replacing all the relative folders with hardcoded versions.

         

        Using relative folders do not work if I want to move the project to another location. We develop on a pc where the project is located on the C-drive. Our build-environment drops the project on D:

         

        Our shared script units are on C: . Poof, can't find the script units anymore because the references are logical.

         

        Same with the log directory. If I check the log directory in current project properties, it literally reads 'C:\Temp\Log' , but in the test environment, it writes the log to D:\Temp\Log because in secret, in the .mds file the log dir is specified as '\Temp\Log'.

         

        I think that the log directory should read what's specified in the .mds file, not do a smart conversion because your project happens to be on the C-drive. This is just confusing.

         

        Some kind of option 'use logical paths' would be a nice to have.

  • Hi marinb ,

     

    If you want to locate the path of each script file you can use the following script by validating the Script directory from the Project local folder

     

     

    Sub TestFile
    
        Log.message VerifyIfFileExistsInDirectory("Test.svb", "Script" )
    
    End Sub
    
    
    
    Function VerifyIfFileExistsInDirectory(RequiredFileName, DirectoryName)
    
    DirectoryPath = VerifyIfDirectoryExists(DirectoryName) if DirectoryPath <> "" then Set fso = CreateObject("Scripting.FileSystemObject") Set folder = fso.GetFolder(DirectoryPath) ExistingFileCount = folder.Files.Count i = 0 For Each f In folder.Files i = i + 1 If f.name = RequiredFileName then VerifyIfFileExistsInDirectory = f.Path Exit For ElseIf i = ExistingFileCount then VerifyIfFileExistsInDirectory = "" Log.Error RequiredFileName & " File does not exist in the directory "&DirectoryName End if Next End if End Function Function VerifyIfDirectoryExists(DirectoryName) LocalPath = Project.Path Set fso = CreateObject("Scripting.FileSystemObject") Set folder = fso.GetFolder(LocalPath) ExistingFolderCount = folder.SubFolders.Count i = 0 For Each f In folder.SubFolders i = i + 1 If f.name = DirectoryName then VerifyIfDirectoryExists = f.Path Exit For ElseIf i = ExistingFolderCount then VerifyIfDirectoryExists = "" Log.Error DirectoryName & " directory does not exist" End if Next End Function