Forum Discussion

tarunaggarwal23's avatar
tarunaggarwal23
Occasional Contributor
5 years ago
Solved

Persisting UI Object

Is it possible to persist UI object variables across automation runs?

 

I have a peculiar scenario:

1. I am invoking TestComplete functions from Java. 

2. From Java, I call TestComplete Functions to launch App 1 and App 2.

3. From Java, I call a TestComplete Function to pefrorm certain action on the App 1 UI.

4. From Java, I call a TestComplete Function to pefrorm certain action on the App 2 UI.

5. Now again from Java, I want to call a TestComplete Function to pefrorm certain action on the App 1 UI.

 

At step 5, the objects recognized during step 3 are no longer valid. So, just wondering if it is possible to persist the UI objects and Arrays created in step 3, and resuse them directly in step 5.

 

Any suggestions / workarounds please?

5 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    While generally speaking this might appear to be possible (your description is just not detailed enough), persistance of the variables that keep references to UI objects is far not the best practice.

    The reason is that if the referenced object is re-created by the tested application, its reference that is kept in the variable will be invalidated. This will result in .Exists property to return False and test code will need to search for the new object again.

    Exact implementation of test code (its architecture) obviously depends on your knowledge of the tested application internals, but you need to keep in mind the above details.

     

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    No.  Variables are emptied and re-initialized between test executions.  

    • Marsha_R's avatar
      Marsha_R
      Champion Level 3

      https://support.smartbear.com/testcomplete/docs/testing-with/variables/data-types/object.html

      Object type variables have global visibility scope and can be used to obtain an object from any keyword test or script unit or to exchange data between tests or units. These variables are available even when a test run is terminated and script variables do not exist.

       

       

       

      If all your steps are being run in one pass inside one project or project suite, then you have project variables or project suite variables that will persist.  Once the test run ends, then the values are gone.