public static GetStartButton ( ) : |
||
Résultat |
public void MyTestInitialize() { // Find the Start button, which will be our target AutomationElement trueStartButton = AutomationElementTest.GetStartButton(); this.startButtonHwnd = (IntPtr)trueStartButton.Current.NativeWindowHandle; }
public void TestInvokeEvent() { AutomationElement startButton = AutomationElementTest.GetStartButton(); BasicChangeHandler handler = new BasicChangeHandler(); Automation.AddAutomationEventHandler( InvokePattern.InvokedEvent, startButton, TreeScope.Element, new AutomationEventHandler(handler.HandleEvent)); handler.Start(); InvokePattern invoke = (InvokePattern)startButton.GetCurrentPattern(InvokePattern.Pattern); invoke.Invoke(); System.Windows.Forms.SendKeys.SendWait("{ESC}"); Assert.IsTrue(handler.Confirm()); Assert.IsNotNull(handler.EventSource); Automation.RemoveAutomationEventHandler( InvokePattern.InvokedEvent, startButton, new AutomationEventHandler(handler.HandleEvent)); }