Forum Discussion

Philip_Baird's avatar
Philip_Baird
Community Expert
11 years ago

Determining the Test Complete Script Extension path

Hi, I have a requirement to provide an editable, unbundled configuration file with a Script Extension where:

 


1. The config file should Live in the same folder as the Script Extension


2. The path to the config file should be able to be dynamically evaluated by the Script Extension


 


To this end I have written the following function to obtain the Test Complete Script Extension path:


 




function getTestCompleteScriptExtensionPath() {


  var scriptExtPath = "";


  var scriptExtSubPath = "Extensions\\ScriptExtensions";


  var proc = Sys.WaitProcess( "TestComplete" );


 


  if( proc.Exists ) {


    scriptExtPath = aqFileSystem.GetFileFolder( proc.Path );


    scriptExtPath += ( scriptExtPath.charAt( scriptExtPath.length - 1 ) === "\\" )


      ? scriptExtSubPath


      : "\\" + scriptExtSubPath;


  }


  


  return scriptExtPath;


}




 


This works, but I was wondering if this is the best or safest method to obtain this path?


 


Regards,


Phil Baird

2 Replies

  • Hi Phil,



    If I understand it correctly, your config and script extension are a part of same folder. Getting CurrentFolder should get you the required path, no? You could use following to obtain the path:



    if from within TestComplete:

    aqFileSystem.GetCurrentFolder



    if from external script file (VBS), which is a part of your script extension:


    set oShell = WScript.CreateObject ("WScript.Shell")


    WScript.Echo (oShell.CurrentDirectory)

  • Philip_Baird's avatar
    Philip_Baird
    Community Expert
    Hi Amar, unfortunately neither of those methods work, they simply return what is, I assume, the current working directory, which is more like the Project path than the Script Extension path.

     


    Regards,


    Phil Baird