Forum Discussion

yogeshharsh's avatar
yogeshharsh
Occasional Contributor
11 years ago

passing variables in programming units

Scenario

My system under test is an application built in JavaSwings and i am trying to come up with a framework for the same. I am using VBscript and using modular approach in test complete. I have categorized the objects in one of the programming units and actions in the other programming units.I need to send the address of objects to the programming unit where functions are present for actions so that i can perfprm actions on those objects. 

 

Problem

How do i send the address of these objects to another programming usnits ?

 

I know i can do it by passing them as arguements and then calling the same functions in the other programming units but it might get difficult at a later stage when i will have so many of objects added in one of the functions in a programming unit.I do not want to use Namemapping feature also.

 

It would be helpful if someone can help me out of the situation .

 

Thanks

yogesh

3 Replies

  • Marsha_R's avatar
    Marsha_R
    Icon for Champion Level 3 rankChampion Level 3

    Use a persistent/project variable for anything you want to share between programming units.  If the value is going to be used as an object, then be sure to use the eval function when you retrieve it.

    • yogeshharsh's avatar
      yogeshharsh
      Occasional Contributor

      It did not work either by using the Project/persistent variables as my requirement is to capture all the objects in programming units which are separated by the screens i.e. a programming unit for a screen having all of its objects.

       

      Somehow i trued using the Arrays and then equating the same to the respective functions which i call in other programmig units and collect the objects to perform an action on those objects.Doing this allows me to have an easy maintenance of the scripts in case if there are any changes in the objects names/properties. It worked quite well but i am stuck on another situation in which i will have to create as many different functions as many new windows/screens or even dialogue boxes are there.

       

      To make it easy to understand (if its confusing :)) below is my plan:

      i have programming units like --Objecs_login (this holds all the objects on the login screen like

      Function Login()

      LoginBtn=Sys.Process("App")......

      Dim arr_o

      Arr(0)=LoginBtn

      Login=arr_o

      End Function )and then i have  another unit like Object_Main_screen (this holds objects present on the main screen after userlogs in like function MainScreen()

      DrpdnApp=Sys.Process("Java").Login("blabla").Panel("blabla").....

      Dim arr_p

      Arr_p(0)=DrpdnApp

      MainScreen=arr_p

      End Function)

       

      Now i am using a progg unit as Action_Library having functions like :

      Function Logging_in()

      Dim a_arr_o

      set a_arr_o==object_login.Login

      call a_arr_o(0).keys("user")

      End Function

       

      or 

      Function Click_app()

      Dim a_arr_p

      set a_arr_p==object_login.MainScreen

      call a_arr_p(0).Click("App")

      End Function

       

      -------------------------------------

       

      My problem is  Can i combine my functions where i am declaring the objects (addresses) ? Because when i do this, test complete tries to search the objects which are not present right now for ex. if i define all the objects of  login screen and main screen in the same function then test complete throws an error saying it could not find the objects which are actually from Main screen which is true as thise objects are not present in screen yet. It does not  even try to login to the application for which the objects are available and doing so can make those objects (of main screen) present too which is being searched by Test complete. I have used the multiple functions just to overcome this issue otherwise i wanted to usea single programming unit or function specifically dedictaed to the objects so that it can be maintained well in the future in the event of changes in the application.

       

      Can you please suggest some solution if i was able to convey this simple but comlex puzzle ??

       

      Thanks

      yogesh

      • Marsha_R's avatar
        Marsha_R
        Icon for Champion Level 3 rankChampion Level 3

        I do understand what you are trying to do, but I don't know a way around the issue with the objects.  As far as I know, they're always going to be verified before the code is allowed to run.