Forum Discussion

edtan's avatar
New Contributor
6 years ago

Sys.Refresh() prevents Window object from being recognised as VCLObject



The Delphi application I am testing starts with this flow:

Splash screen -> login screen -> main window.


The main window is represented as a Window object in the object browser and is available at launch. However it only gets recognised as a VCLObject once the login screen appears (~20 secs later on my machine). I've observed this behaviour both from launching the application manually and launching it as part of a test script using TestedApps.Run.


The issue is when I refresh the object tree programatically before the login screen appears, either using Sys.Refresh() or Process(..).Find with the refresh parameter set to true, the main Window object never gets recognised as a VCLObject.


However, if I pause test script execution and refresh the object tree manually in the Object Browser, the VCLObject sometimes appears. When it doesn't appear, I need to either highlight the window by right clicking the Window object and selecting "Highlight on screen", or by inspecting the window using the Object Spy. Refreshing the object tree after performing either of these actions causes the VCLObject to appear.


So my questions are:

  1. What can cause the Window object to take so long to be recognised as a VCLObject?
  2. Why does programatically refreshing the object tree cause the Window object to never be recognised as a VCLObject?


I am using TestComplete 11.31.2420.7 on Windows 7.

Any advice or help is appreciated. Thank you.

  • In re-reading your post, you're using the "Find" method and using the "Name" property of the object to find what you're looking for.

    Name is not a recommended property to use, to be honest. A better way would be to examine the object and pick a set of properties that uniquely identify it.  You can then pass them as arrays to the find object.

8 Replies

  • Have you done name mapping for your main form?

    I my testing enviroment mapped VCLObjects are show as greyed (disabled) in Object browser.

    I'm using 12.6.



  • Hi ,

    I used to get problem to recognise the VCLObjects .

    Some times I even gets objects with T prefix. I tried launching the application with TestedApps and with sufficient delays. Also I am using Namemapping. Now I can see the test running properly.


    • edtan's avatar
      New Contributor

      Thanks for the replies.


      Yes, the main window is name mapped.


      However, I am not accessing the object via it's mapped names. Instead, I am using the Process.Find method on the Name property to find and access the VCLObject since I am trying to remove the dependency on NameMappings.

      • tristaanogre's avatar
        Esteemed Contributor

        You will lose performance using "Find" instead of NameMapping.  The Find methods are pretty performance taxing as they need to do a scan of the object tree via the code engine where as the NameMapping engine is built in and optimized.

        Is there a reason why you are bypassing the NameMapping?


        As for your questions:


        1) Are you running with debug info agent against your Delphi application?  If so, that does cause a bit of a start up delay as it needs to read the info in.  

        2) Not entirely sure why this is the case, but my guess from working with other desktop applications is that there are processes in the application that need to complete before the components can be recognized.  I'm assuming the object is there, just not showing as "VCL(blah)"?  

        You can try using FindEx (I think this is available in TC 11).  This does the find with a timeout delay that you can tell it to try and find the object within a certain time period.