Ranorex spy does not identify custom WPF-Shape-Descendant (with AutomationPeer)

Ranorex Studio, Spy, Recorder, and Driver.
kkr
Posts: 4
Joined: Wed Jan 09, 2019 2:45 pm

Ranorex spy does not identify custom WPF-Shape-Descendant (with AutomationPeer)

Post by kkr » Wed Jan 09, 2019 3:25 pm

Hi.

We are trying to identify Polygons drawn on a Canvas in a WPF-Application with Ranorex Spy.

Because the default Polygon class do not create an AutomationPeer, we use a custom implementation "AutomationPolygon" which inherits from Shape and implements OnCreateAutomationPeer (as suggested in wpf-support-of-system-windows-shapes-av ... t1059.html). The created AutomationPeer is a custom class "PolygonAutomationPeer", which sets the AutomationControlType as "Image".

I have attached a very simple demo application. Microsoft Inspect successfully identifies the custom shapes - but Ranorex Spy does not (version 8.1, launched as Administrator on a Windows 10 machine).

Could you please advise how to fix this problen, and/or provide an example how custom AutomationPeers have to be implemented in order to show up in Ranorex Spy?

Thank you very much.
You do not have the required permissions to view the files attached to this post.

User avatar
RobinHood42
Posts: 324
Joined: Fri Jan 09, 2015 3:24 pm

Re: Ranorex spy does not identify custom WPF-Shape-Descendant (with AutomationPeer)

Post by RobinHood42 » Thu Jan 10, 2019 7:39 am

Hi,

Please try to set the WPF plugin setting to "UiaPreferred":

UIAPreferred.png

Was able to detect the image on my machine.

Cheers,
Robin :mrgreen:
You do not have the required permissions to view the files attached to this post.

kkr
Posts: 4
Joined: Wed Jan 09, 2019 2:45 pm

Re: Ranorex spy does not identify custom WPF-Shape-Descendant (with AutomationPeer)

Post by kkr » Thu Jan 10, 2019 1:07 pm

Works like a charm! Thank you for your help!

Cheers,
Karsten

kkr
Posts: 4
Joined: Wed Jan 09, 2019 2:45 pm

Re: Ranorex spy does not identify custom WPF-Shape-Descendant (with AutomationPeer)

Post by kkr » Fri Jan 11, 2019 11:01 am

One additional question:

When I Click on "Track" in Ranorex Spy, and I hover with the mouse over the TitleBar, its bounding box is shown as a red rectangle.
However, when I hover over my Shapes, the bounding box is not shown immediately. I have to click in the window, then look for my shapes in Ranorex Spy.

Can the shapes be set up in a way, so that their bounding box is shown when hovering over the shapes in the application? The direct visual feedback would be helpful (though not essential) for the person designing new tests.

Thanks,
Karsten

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex spy does not identify custom WPF-Shape-Descendant (with AutomationPeer)

Post by odklizec » Fri Jan 11, 2019 11:57 am

Hi,

If track does not show the highlight only on your custom-drawn objects, then I would say their implementation is not exactly Ranorex-friendly? ;) It would be good if you send a small sample app (ideally with source code) to Ranorex developers, so they can analyze the problem and eventually suggest a change in your app, eventually, improve tracking functionality.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

kkr
Posts: 4
Joined: Wed Jan 09, 2019 2:45 pm

Re: Ranorex spy does not identify custom WPF-Shape-Descendant (with AutomationPeer)

Post by kkr » Fri Jan 11, 2019 12:56 pm

A C# solution demonstrating the problem is attached to my original post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex spy does not identify custom WPF-Shape-Descendant (with AutomationPeer)

Post by odklizec » Fri Jan 11, 2019 1:37 pm

Sorry, I overlooked that the zip contains sample app ;) I compiled it and it seems the highlight works for me, but there are some weird differences.

With wpf plugin set to UIAOnly, highlight (when hovering mouse over) works just for polygon2 and both elements are identified as picture. An interesting part is, that MS Inspect shows exactly the same behavior. It only highlights polygon2.

After switching wpf plugin to WPFOnly, both triangles are identified as "element" (with many wpf attributes, which are not available with UIAOnly) and highlight works for both elements too. The only problem is, that the red rectangle does not match the exact rectangle size of each triangle? Each rectangle starts from 0,0 point of application form, instead of starting from left-top corner of polygon boundary. I think it's definitely something that should be checked by Ranorex devs.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration