TestStack | How to find custom controls and invoke methods / fire events

后端 未结 1 893
独厮守ぢ
独厮守ぢ 2021-01-27 12:12

I have a custom Control HtButton which inherits from Control.

I made a custom FrameworkElementAutomationPeer and override the

1条回答
  •  孤独总比滥情好
    2021-01-27 12:47

    There are other solutions I guess, some of which are a bit involved in my opionion (i.e. creating a custom UIItem subclass and so on).

    What I finally went for is this:

    var myButtons = Window.GetMultiple(SearchCriteria.ByClassName("HtButton"));
    foreach (var button in myButtons )
    {
        dynamic t = button;
        t.Foo();
    }
    

    It does definitely work, it's short and just requires you to reference Microsoft.CSharp.

    0 讨论(0)
提交回复
热议问题