Forum Discussion

Manfred_F's avatar
Manfred_F
Regular Contributor
4 years ago
Solved

Object sometimes doesn't support Exists

had similar problems as described in

https://community.smartbear.com/t5/TestComplete-Desktop-Testing/Object-sometimes-doesn-t-support-Exists/td-p/183729/page/2

 

In my case, not only the .Exists property of alias objects was affected, but also .Exists, .Child, .ChildCount, .MappedName, .Parent properties of normal controls. I use alias objects only to identify dialogs, then navigate down the hierarchy..

 

The workaround is to access the control's .FullName property before accessing anything else.

So: for alias objects, call .refreshMappingInfo(), for controls get .FullName.

 

I'm still using TC11.30..

  • sonya_m's avatar
    sonya_m
    4 years ago

    Thank you for trying to help, Marsha, Alex!

     

    Hi Manfred_F ! I am sorry to hear that you keep facing this. Perhaps the Support team will be able to investigate this deeper? I would suggest opening a ticket like Marsha said since it looks like none of the suggested approaches here helped. 

    And, of course, I will really appreciate it if you post the final solution to this thread when you get it. Thank you.

8 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    I am guessing that you are working with the desktop application, aren't you?

    How the reference to the object was obtained?

     

    • Manfred_F's avatar
      Manfred_F
      Regular Contributor

      Yes, I work with the desktop application.

      The references are obtained as follows:

      1) use alias to access the dialog

      2) use child, children etc to step down the hierarchy.

       

      The effect showed up from within script extensions and from native vb code also. The effect reproducibly occurred at specific locations in my scripts and did not occur at many others.

      I'm quite sure that it is not a timing issue.

       

      Regards,

      Manfred

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        This is weird... For desktop applications, object that is accessed via Aliases and .Child() calls must always contain .Exists property.

        The only case when this may not happen is when test code references an object through the 'chain' of its parents and some object within this 'chain' does not exist.

        E.g. if for the Aliases.App.MainForm.Subform.UserNameTextBox.Exists line of code the Subform object does not exist (or any intermediate object that exists in NameMapping but is excluded from the Aliases tree), then UserNameTextBox may not contain .Exists property.

        But for this case I would expect an error in the test log stating that Subform object was not found.

        May the above be your case?

        Can you provide a code sample that illustrates the problem that you have?

         

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Does it work properly if you step through the code with Debug?  If so, there's a timing issue to hunt down.