Page 1 of 1

How to find WpfElement if mode is UiaPreferred

Posted: Tue Aug 15, 2017 11:36 pm
by merklh
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.

Re: How to find WpfElement if mode is UiaPreferred

Posted: Wed Aug 16, 2017 6:50 am
by odklizec
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? ;)

Re: How to find WpfElement if mode is UiaPreferred

Posted: Wed Aug 16, 2017 5:21 pm
by merklh
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 .