How to find WpfElement if mode is UiaPreferred

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
merklh
Posts: 24
Joined: Thu Jan 03, 2013 6:55 pm

How to find WpfElement if mode is UiaPreferred

Post by merklh » Tue Aug 15, 2017 11:36 pm

We have a screen in our app where the WPF adapter returns more info than UIAutomation returns. Most of our code is written for UIAutomation so we want to only use the WPF adapter as needed. Using the WPF adapter only is not an option because we have seen problems with old code that can't be changed at this time.

I have tried to call WpfElement.FromPath() but this causes an exception "The element does not support the required capability 'wpfelement'". I assume this is because Ranorex finds the UIAutomation element first in the tree. In Spy I can see two trees, the first for UIAutomation and the second for WPF.

Is there a way to force WPF only mode for one call?

I hope the question makes sense.

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

Re: How to find WpfElement if mode is UiaPreferred

Post by odklizec » Wed Aug 16, 2017 6:50 am

Hi,

I would suggest to check this post about switching uiapreferred/wpfpreferred mode from code:
https://www.ranorex.com/forum/how-to-se ... t7820.html

I'm not quite sure if it solves your problem, but I think it's worth a try? ;)
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

merklh
Posts: 24
Joined: Thu Jan 03, 2013 6:55 pm

Re: How to find WpfElement if mode is UiaPreferred

Post by merklh » Wed Aug 16, 2017 5:21 pm

odklizec wrote:Hi,

I would suggest to check this post about switching uiapreferred/wpfpreferred mode from code:
https://www.ranorex.com/forum/how-to-se ... t7820.html

I'm not quite sure if it solves your problem, but I think it's worth a try? ;)
That's what I ended up doing right after posting this :-). Seems to work though it doesn't feel right to change configuration all the time .