Message is getting printed twice in logs of testcomplete
Hi Team ,
Below mentioned code for my project is creating problem. Log.Message(finalPath); is getting printed twice in the logs. First with correct path and second time with \\..\\..\\undefined in the last . Please help me to correct this problem .
eval(Include("GlobalConstants.js"));
function Include()
{
var projectPath = Project.Path;
var filePath = projectPath + "Script\\" + arguments[0];
var finalPath = filePath.replace(/\\/g, "\\\\");
Log.Message(finalPath);
var fSO = new ActiveXObject("Scripting.FileSystemObject");
var readFile = fSO.OpenTextFile(finalPath, 1);
while(!readFile.AtEndOfStream){
var readLine = readFile.ReadLine();
}
readFile.Close();
return readLine;
} // End Include()
To run the Include() routine, the entire file is first processed. In this phase, you run the eval() command and define the Include() function. You are probably trying to run this routine by right-clicking in the routine and selecting "Run current routine", or perhaps you defined a Project Test Item to call the Include() routine and then running the project. What you are doing is effectively this:
Include("GlobalConstants.js"); Include();
The second call has no arguments. Attempting to reference them produces the "undefined".
The Include() routine needs the argument defined. Rewrite as:
function Runme() { Include("GlobalConstants.js"); } function Include(file) { ... }