Forum Discussion

OLEONTYEV's avatar
OLEONTYEV
Occasional Contributor
13 years ago

How to set up correct recognition of non-typical WPF controls.

Hello,

I'm testing a desktop WPF application using TC 8.70.

I have a problem with an incomplete tree of WPF controls in Object Browser (and in scripts, consequently).

The fact is, that I get 2 parallel trees using MSAA and WPF recognition. So, I get some properties and controls using a WPF tree, like that:



Sys.Process('My').WinFormsObject('MainForm').

WinFormsObject('MdiClient','').WinFormsObject('Workspace').WinFormsObject('_controlHostPanel').

WinFormsObject('Host').WinFormsObject('elementHost1').WPFObject('HwndSource: AdornerDecorator', 'elementHost1').

WPFObject('AdornerDecorator', '', 1).WPFObject('ContainerControl', '', 1).WPFObject('host').

WPFObject('WorkspaceView', '', 1).WPFObject('TabHostView', '', 2)




Other controls and properties are exposed using a common MSAA tree, the 1st part of which is the same. But at a certain point, the tree bifurcates, and I can not get it merged:



Sys.Process('My').WinFormsObject('MainForm').

WinFormsObject('MdiClient','').WinFormsObject('Workspace').WinFormsObject('_controlHostPanel').

WinFormsObject('Host').WinFormsObject('elementHost1').WPFObject('HwndSource: AdornerDecorator', 'elementHost1').

Client(0).Client(0).Client(2).TabList(0).PageTab('Configuration').Client(0).Button('Save')



It's one of the shortest side tree examples. And it leads to very bad practices in scripts, when we have to search for objects belonging to the same visual pane, but in different trees. Merging them would be fantastic. But I have added all the available class names to the OpenApplications/WPF page of the project properties, and I've got nothing.



Do I do anything wrong with the settings? Or is it a WPF feature?

3 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Oleg,



    The WPF and MSAA object identification engines are two different independent engines, that's why, they generate different object trees from some point onward. I'm afraid, there's no way to "merge" their object trees, because in most cases, there's no direct correspondence between the WPF- and MSAA-identified objects.





    But I have added all the available class names to the OpenApplications/WPF page of the project properties, and I've got nothing.

    Do I do anything wrong with the settings?
    It's difficult to answer specifically without seeing your tested application and your test project settings.Can you send your tested app and test project to our Support Team for investigation (under an NDA if needed)? They'll look into it and suggest the best options for handling your custom WPF controls.
  • OLEONTYEV's avatar
    OLEONTYEV
    Occasional Contributor
    Thank you, Helen.



    It is not possible for me to send the application, because I'm liable to corporate secrecy rules.

    I just hoped to find some forum inhabitants who had already met such a problem.
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Oleg,



    And it leads to very bad practices in scripts, when we have to search for objects belonging to the same visual pane, but in different trees. Merging them would be fantastic.


    On second thought, if I understand you correctly, a possible solution is to create Name Mapping (object repository) for your tested application and use conditional name mapping in combination with Extended Find to map objects in different branches to the same object hierarchy.

    For example, you can define a mapping condition for an object similar to this:



    (

       [ WPF identification condition ]

       ClrClassName = 'TabHostView'

      AND

       Index = 2

    )

    OR

    (

       [ MSAA identification condition ]

       ObjectType = 'PageTab'

      AND

       ObjectIdentifier = 'Configuration'

    )



    and then refer to this object as, say, Aliases.MyApp.MainForm.Foo.Bar.MyTargetObject, regardless of whether it's in the WPF or MSAA branch.