I am working with a WPF application. I am curious if it is possible to detect if a certain element in the UI is under focus?
The attached screenshot shows 2 fields, the 1st of which has focus. The 2nd one does not.
I found a similar post but it was slightly out of date and I was not sure if it discussing WPFs here: Finding Focus.
~ Max
4 Answers, 1 is accepted
First I can confirm the post you reference was talking about testing a WPF application. It is still true that there is no way how to check if the element is focused.
Regards,
Cody
Telerik
Bummer!
Does test studio allow one to get a reference to a WPF UI element in a running application?
If so, I will be able to test focus.
~ Max
Hey Cody,
We are testing a possible text box for use in our application. Interestingly enough, this control of type RadNumericUpDown has a focus verification option as you can see in the attached screenshot
Is it expected that the RadNumericUpDown has this but a RadButtons or RadOutlookBars do not?
If Test Studio has no way to check what element is focused, what am I seeing here?
Is it in Telerik's road map to make element focus check able?
~ Max
I didn't even know that functionality existed (too many features for me to keep track of them all). That works but only for some of the Telerik Rad controls which have an available translator, as you have already discovered. It won't work for just any UI element in a WPF application. You can use it only to tell if that specific control currently has the input focus at that point in time. It cannot be used to discover which element currently has input focus.
I am not aware of plans in the immediate future to expand on the "has focus" verification.
Regards,
Cody
Telerik