How can I find the what element is being focused on in a WPF application?

5 posts, 0 answers
  1. gnuftw
    gnuftw avatar
    24 posts
    Member since:
    May 2015

    Posted 28 May 2015 Link to this post

    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

  2. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 01 Jun 2015 Link to this post

    Hello Max,

    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
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  3. gnuftw
    gnuftw avatar
    24 posts
    Member since:
    May 2015

    Posted 02 Jun 2015 in reply to Cody Link to this post

    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

  4. gnuftw
    gnuftw avatar
    24 posts
    Member since:
    May 2015

    Posted 02 Jun 2015 Link to this post

    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

  5. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 02 Jun 2015 Link to this post

    Hello 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
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top