Forum Discussion

adi_xyz2000's avatar
adi_xyz2000
Occasional Contributor
11 years ago

WPF elements in ObjectBrowser

I see that not all the layers that are availabe for a WPF application are displayed in Test Complete, Object Browser.



I attach two screen captures, one from TestComplete and one from Snoop.



How can I display in TestComplete all the layers (as in Snoop)?



Thanks.
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Andrei,



    By default, TestComplete hides the layout containers (ContentPresenter, Panel and others) to simplify the test object hierarchy. If you need to use the full object hierarchy:

    1) Go to Tools > Current Project Properties > Open Applications > WPF.

    2) Unselect the Simplified WPF object tree option.



    For details, see About Containers in the WPF Object Hierarchy.
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Andrei,



    Sorry for the confusion. Snoop shows a more detailed object tree than TestComplete indeed, but that's because it also shows some low-level drawing primitives. Let me explain this by an example.



    WPF UI elements are complex and consist of other objects. For example, a simple button:



    <!-- XAML -->

    <Button>Click me!</Button>

    consists of 4 objects:



    Button

      |_ ButtonChrome

          |_ ContentPresenter

              |_ TextBlock



    The component objects are used just to draw the button on screen. The users cannot actually interact with them.



    Snoop is a tool mostly for developers. It shows all the objects including the drawing primitives, because they can be useful for debugging.



    TestComplete, on the other hand, is a test automation tool. It filters out low-level drawing objects that aren't relevant for GUI automation to make the test object model simpler. To check an object's appearance, you can always use the object's own properties rather than work directly with the drawing primitives.



    Hope this answers your question. Let me know if you need any clarification.
  • adi_xyz2000's avatar
    adi_xyz2000
    Occasional Contributor
    Hi Helen,



    Thanks for the answer.



    My issue is that in the implementation the tooltip is embeded in some lower layers than I have displayed.



    In this case, does it make sense to try something like findChild? Will Test Complete access also the layers that are not displayed?
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    The object to which the tooltip is attached should have a property or method that returns the tooltip text. For example, if you have a button like this:



    <!-- XAML -->

    <Button Width="100" Height="25" ToolTipService.ToolTip="This will do nothing though.">Click me!</Button>

    you can get the tooltip text using the button's Tooltip property.



    FindChild doesn't search for internal objects returned by properties; you need to access these internal objects directly through the appropriate property.



    If you could tell us the class name of your tested object, and maybe also posted some screenshots or a sample application, we could give more specific advice on how to access the tooltip.