GuOrg / Gu.Wpf.UiAutomation

MIT License
96 stars 17 forks source link

How to find Edit Control ? #78

Open neilyoung2008 opened 5 years ago

neilyoung2008 commented 5 years ago

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

JohanLarsson commented 5 years ago

What is an edit control?

neilyoung2008 commented 5 years ago

flaUInspect

neilyoung2008 commented 5 years ago

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

neilyoung2008 commented 5 years ago

flaUInspect

JohanLarsson commented 5 years ago

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 commented 5 years ago

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