Forum Discussion

Deef's avatar
Deef
Occasional Contributor
7 days ago

How to compare local variables with a reusable script in TestComplete?

I have created the following script that compares the contents of two project variables. Which two variables exactly can be defined through the parameters param1 and param2. This function can be called from within any keyword test since the variables are global.


function CompareTwoProjectVariables(param1, param2)
{
  if (Project.Variables.VariableByName(param1) == Project.Variables.VariableByName(param2)) {
    Log.message("The contents of variables " + param1 + "(" + Project.Variables.VariableByName(param1) + ")" + " and " + param2 + "(" + Project.Variables.VariableByName(param2) + ")" + " are equal.");
    return true;
    
    } else {
      Log.Error("Variables " + param1 + "(" + Project.Variables.VariableByName(param1) + ")" +  " and " + param2 + "(" + Project.Variables.VariableByName(param2) + ")" + " are not equal.");
      return false;
    }
}

The above script works perfectly for me. However I want to have a similar script that compares two local variables instead. I haven't been able to create a working script, because I can't succeed in calling the local variables correctly.

I hope someone can point me in the right direction.

Thanks