Further investigation has shown that no matter if the variables are of Object type and initialized in main() or any other script in the recursion, they are becoming empty once passed to another test. I moved the initialization code to unit Init as on the screenshot without success.
Because of the above it can be concluded that the error is in the recursion script:
//USEUNIT Database
function Main()
{
var Driver;
Driver = DDT.ExcelDriver("c:\\logon.xlsx", "MKD", true);
RecNo = 0;
Database.resetPass();
while (!Driver.EOF())
{
recursiveTraverse(Project.TestItems);
Driver.Next();
}
DDT.CloseDriver(Driver.Name);
}
function recursiveTraverse(Level)
{
var Items = Level.ItemCount;
for(var i = 0; i <=(Items-1); i++)
{
runTestItemRoutine(Level.TestItem(i));
recursiveTraverse(Level.TestItem(i));
}
}
function runTestItemRoutine(TestItemLevel)
{
if (TestItemLevel.ElementToBeRun != null)
{
var caption = TestItemLevel.ElementToBeRun.Caption.split("\\");
if (caption[0] == "Script")
{
var script = caption[1].split(" - ");
if (script[1] != "Main")
{
Runner.CallMethod(script[0] + "." + script[1]);
}
}
}
}
function recursiveTraverse(Level)
{
var Items = Level.ItemCount;
for(var i = 0; i <=(Items-1); i++)
{
runTestItemRoutine(Level.TestItem(i));
recursiveTraverse(Level.TestItem(i));
}
}
function runTestItemRoutine(TestItemLevel)
{
if (TestItemLevel.ElementToBeRun != null)
{
var caption = TestItemLevel.ElementToBeRun.Caption.split("\\");
if (caption[0] == "Script")
{
var script = caption[1].split(" - ");
if (script[1] != "Main")
{
Runner.CallMethod(script[0] + "." + script[1]);
}
}
}
}
and Init contains:
function Init()
{
user = DDT.CurrentDriver.Value('user');
Log.Message(user);
password = DDT.CurrentDriver.Value('password');
Log.Message(password);
accounts = Database.getAccounts(user);
Log.Message(accounts);
}
If anyone has managed to recursively run Test Items with a DDT driver and use project variables at the same time, help will be greatly appreciated
Thanks in Advance,
Ilija