Gu.Wpf.UiAutomation icon indicating copy to clipboard operation
Gu.Wpf.UiAutomation copied to clipboard

How to find Edit Control ?

Open neilyoung2008 opened this issue 5 years ago • 6 comments

FindChildAt(Index)is work,but SOMETIMES the index is not const in different app version, why not add the interface named FindEdit like “FindTextBox" ?

neilyoung2008 avatar Apr 08 '19 08:04 neilyoung2008

What is an edit control?

JohanLarsson avatar Apr 08 '19 10:04 JohanLarsson

flaUInspect

neilyoung2008 avatar Apr 08 '19 10:04 neilyoung2008

class name is Edit , control type is Edit , as above .

neilyoung2008 avatar Apr 08 '19 11:04 neilyoung2008

flaUInspect

neilyoung2008 avatar Apr 08 '19 11:04 neilyoung2008

What does the xaml for the control look like?

There is API for finding custom controls but it is not pretty. Something like below should work:

var edit = window.FindFirst(
    TreeScope.Descendants,
    new AndCondition(Conditions.ByClassName("Edit"), Conditions.ByControlType(ControlType.Edit)),
    x => new EditControl(x),
    Retry.Time);

Where EditControl is your custom wrapper.

If this is a WPF control we should definitely support it in a better way.

JohanLarsson avatar Apr 08 '19 12:04 JohanLarsson

Can you make a pull request with a window containing the control? Placing it in this folder would be perfect: https://github.com/GuOrg/Gu.Wpf.UiAutomation/tree/master/TestApplications/WpfApplication/Windows

JohanLarsson avatar Apr 08 '19 12:04 JohanLarsson