How to define global variables using scripts
Hi folks,
I want to declare and use self defined global variables across a complete test flow execution. The Test Flows encompass multiple script (JScript) files and multiple functions (I dont want to use Project or Project Suite Variables).
I tried to do the following but its not working:
//Defined a script file variables.sj. This file had this code:
var myGlobalVariable = 9;
Log.Message("01. Global value of 'myGlobalVariable': " + myGlobalVariable);
function setVariables()
{
myGlobalVariable = 10;
Log.Message("02. Local value of 'myGlobalVariable': " + myGlobalVariable);
}
Log.Message("03. Global value of 'myGlobalVariable': " + loginArray);
//Defined another script file useGlobalVariables.sj. This file had this code:
//USEUNIT variables
function useGlobalVariablesFunction()
{
variables.setVariables();
//I know this function above will not set the values outside its scope.
log.Message("Calling global variable: " + variables.myGlobalVariable);
}
Executing the function 'useGlobalVariablesFunction' throws an error: 'Object doesn't support this property or method'
Regards,
OS
Issue resolved. It was a typo error :( my bad