How can I simulate the press of a button?

前端 未结 5 711
天命终不由人
天命终不由人 2021-01-18 15:25

I want to test some forms. Is there a way to simulate the press of an Ok (or Cancel) button so that the button is pressed and fires the event handlers that are associated wi

5条回答
  •  抹茶落季
    2021-01-18 16:08

    It's better to use the PerformClick() method of the Button =>

    button1.PerfomClick()
    

    If your Button is not in the right state to click (enabled false or not visible), it will not perform the click eventmethod.

提交回复
热议问题