Forum Discussion

vinodkumar_chau's avatar
vinodkumar_chau
Contributor
11 years ago

how to include external file in test complete project suite

Hi,

 

I am using eval method to include an external file in my project which reads the file from my desktop.

Is it possible to read the same file from project location path.

If something like below is possible then it would be of great help.

 

Dir/CommonSource

Dir/Project1

Dir/Project2

 

In

Dir/CommonSource i can keep my all common files , and then i can  use it with all my projects.below is the sample code that i am using.but this is not fullfilling my requirement as we want to have project directory stuc like i said above - Dir/... , Dir/... etc

 

eval(Include("Global-Constants.js"));

function Include()
{
    var myDocuments = 5;
    var objShell    = new ActiveXObject("shell.application");
    var objFolder   = objShell.NameSpace(myDocuments).self.path;
    var fileName    = objFolder+"\\TestComplete 10 Projects\\CommonFiles\\"+ arguments[0];
    var fSO         = new ActiveXObject("Scripting.FileSystemObject");
    var readFile    =  fSO.OpenTextFile(fileName, 1);
    var str         = readFile.ReadAll();
    return str;
} // End Include()

 

Thanks

Vinod

2 Replies

  • colinstrydom's avatar
    colinstrydom
    Occasional Contributor

    If I understand the question correctly, you only want to get the current project path, you can simply use this

     

    ProjectSuite.ConfigPath + '\\folder'

     

    Hope this helps

  • Hi Vinod,

     

    Also, You can execute an external file from the TestComplete test. For example:

    Set ws = Sys.OleObject("WScript.Shell")
    ws.Run("c:\somefile.vbs")