Forum Discussion

forrestaustin's avatar
forrestaustin
Contributor
6 years ago
Solved

Is there a way to search for a WPF control or window by its text

I can't identify my applications tooltips using the object browser, so I am wondering if there is a way that I can search the object browser for a text string matching the tooltip text to try and figure out how I can identify it in the future.

 

Is there a simple way to do this?

  • AlexKaras's avatar
    AlexKaras
    6 years ago

    Hi,

     

    > The code just creates a new tooltip object.

    As per documentation (for example, https://docs.microsoft.com/en-us/dotnet/framework/wpf/controls/tooltip-overview) tooltip object must not just be created, but also associated with the target object. (Though I believe that this is done in the real application.)

    I was not able to find yet if tooltip in WPF is a windowed or window-less object. If the latter, it should not be displayed in the Object Browser.

    Anyway, I think that you should carefully investigate the target control (button, etc.) in the Object Browser and search for the property that contains tooltip text.

    You may also talk one more time to developers and ask them how they assign tooltip to the control. I can imagine the scenario, when the control has, for example, OnMouseOver event handler and tooltip is set within this handler and removed by another handler when mouse leaves control's boundaries.

    In this case you will need to know the name of the control's property that contains tooltip text and just refer to this property 'blindly' from test code. (Because, obviously, you will never see tooltip text for the control if the mouse does not hover it.)

     

  • AlexKaras's avatar
    AlexKaras
    6 years ago

    Hi,

     

    > TC could not at all recognize that that entity existed on the screen. 

    I think that this is the consequence of the incorrect implementation of tooltip (as per your words and referenced documentation) and is an implicit proof that Tooltip is a windowless object (like TLabel in Delphi).

    Basically, TestComplete can recognize only those window objects of the tested application that are registered in the system during runtime. These are the objects that you can spy using, for example, Spy++ utility provided by Visual Studio. You may try and check if you can identify (incorrectly implemented) tooltip object using Spy++. If tooltip cannot be identified, this is one more reason to think that Tooltip is a windowless object.

    In addition to the above, TestComplete implements additional logic to be able to identify additional objects that are visible on the screen but are not registered as window objects in the system. Obviously, to be able to do this, those objects must follow some rules and/or requirements.

    To my opinion, the fact of instantiation of the tooltip object during runtime means nothing and cannot be processed by TestComplete if the instantiated tooltip is not tied to some UI control.

    This is how I see it.

     

11 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Not as such, no.  I believe AlexKaras mentioned in another thread contacting your developers and finding out from them where the tooltip is found.  Basically, it sounds like it is a property or something on another component.  So, once you find out how it is implemented, then all you need to do is just look for that property every time.

    • forrestaustin's avatar
      forrestaustin
      Contributor

      Hi,tristaanogre. Thanks for the reply.

       

      Yes he did suggest that here. https://community.smartbear.com/t5/TestComplete-General-Discussions/Object-Browser-shows-grey-boxes-for-some-parts-of-application/m-p/172068#M31921

       

      As I said in that post, I did go talk to them and I saw the code. The code just creates a new tooltip object. It looks something like this:

       

      public System.Windows.Controls.ToolTip m_popup = new System.Windows.Controls.ToolTip();

       

      So, it creates a new tooltip object. Even with this information I can't seem to figure it out.

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        > The code just creates a new tooltip object.

        As per documentation (for example, https://docs.microsoft.com/en-us/dotnet/framework/wpf/controls/tooltip-overview) tooltip object must not just be created, but also associated with the target object. (Though I believe that this is done in the real application.)

        I was not able to find yet if tooltip in WPF is a windowed or window-less object. If the latter, it should not be displayed in the Object Browser.

        Anyway, I think that you should carefully investigate the target control (button, etc.) in the Object Browser and search for the property that contains tooltip text.

        You may also talk one more time to developers and ask them how they assign tooltip to the control. I can imagine the scenario, when the control has, for example, OnMouseOver event handler and tooltip is set within this handler and removed by another handler when mouse leaves control's boundaries.

        In this case you will need to know the name of the control's property that contains tooltip text and just refer to this property 'blindly' from test code. (Because, obviously, you will never see tooltip text for the control if the mouse does not hover it.)