Forum Discussion

vinodkumar_chau's avatar
vinodkumar_chau
Contributor
10 years ago
Solved

Reading files from ProjectFolder Path in testcomplete

Hi All ,

 

I have a file at this path in Project Itself "C:\Users\vinodkumar.chaudhary\Documents\TestComplete 10 Projects\CommonFiles". 

CommonFiles is the folder created to keep all the common files. If i have to read a common file like 'common.js' from commonfiles folder , how should i do it using eval(Include...). I dont want to give complete path. For ex like below

 

eval(Include("../../../CommonFiles/common.js"));

function Include()

{

Code to read file

}

  • Hi.

     

    The folder you're trying to reach can be addressed as ..\..\CommonFiles\

     

    Following is how your example should look like:

    eval(Include("..\\..\\CommonFiles\\common.js"));

     

    Don't forget that double backslashes instead of single ones are needed only in contsants (direct assignments) and not needed if passed as KDT parameters or project or suite variables.

     

    Regards,

    Andrey

     

3 Replies

  • Hi.

     

    The folder you're trying to reach can be addressed as ..\..\CommonFiles\

     

    Following is how your example should look like:

    eval(Include("..\\..\\CommonFiles\\common.js"));

     

    Don't forget that double backslashes instead of single ones are needed only in contsants (direct assignments) and not needed if passed as KDT parameters or project or suite variables.

     

    Regards,

    Andrey

     

  • Ravik's avatar
    Ravik
    Super Contributor
    Hi Vinod, You can use Project Variable for this. You have to define a project variable like - "ProjectPath", "ProjectName" and valid your files like below FRAMEWORK_ROOTPATH = GetParentFolderAtDepth(Project.Path,3) strProjectPath = Trim(FRAMEWORK_ROOTPATH & Project.Variables.ProjectPath & "\" & Project.Variables.TestProjectName) If g_fso.FolderExists(strProjectPath) then log.Message "Project path successfully found for automation project " _ & Project.Variables.TestProjectName Else log.Error "Project path was not found for automation " & Project.Variables.TestProjectName &_ " project path should be " & strProjectPath & " for automation project" & Project.Variables.TestProjectName End If