Forum Discussion

ilija_panov's avatar
ilija_panov
Contributor
13 years ago

Project variables of string type getting empty between tests

Hi to All,



I'm opening this topic in relation to issue described in http://community.smartbear.com/forum/post/?mode=singleThread&thread=a4082b03-4d2c-4ab5-9131-3f4383b0e4dd



I have two project variables getting filled form a DDT driver in the main() recursive function cycling through the test items as described in the post above, but when I passed them to tests in the recursion they are empty. otherwise I have been using the same variables without the recursion and seem to work fine. Would really appreciate if someone can take a look at what is causing this problem



Thanks,

   Ilija
  • I even tried with user and object variables of Object type and that doesn't work as well:-(. 



    For sure there must be something wrong with the recursive function 




    function Main()

    {

      var Driver;

      Driver = DDT.ExcelDriver("c:\\logon.xlsx", "MKD", true);  

      RecNo = 0;

      while (!Driver.EOF())

      { 

        user = DDT.CurrentDriver.Value('user');

        Log.Message(user);

        password = DDT.CurrentDriver.Value('password'); 

        Log.Message(password);

        accounts = Database.getAccounts(user);

        Log.Message(accounts);

        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]); 

          }

        }

      }

    }



    Otherwise the project variables can be passed without any problem but when the same tests usign them are called in the recursive function they are becoming empty. Any help is appreciated.



    Thanks in advance,

        Ilija



  • VLapidus's avatar
    VLapidus
    Frequent Contributor
    It seems that the issue was solved in the thread in the first post
  • Yes, after some further investigation I managed to nail down the issue to  Runner.CallMethod()   



    However another problem arises is that the number of variables passed through CallMethod must be fixed and in the strictly specified order, not like the usual args, argv[] syntax when passing parametars in traditional programming languages.



    Since the Project .Variables used are global in scope it does not make sense to pass them like parameters when calling functions, seems much better to use them whenever neccesary inside the functions  which I will try doing today.



    Thanks a lot for the support,



    Ilija