public void TestStructureChangeEvent() { StructureChangeHandler handler = new StructureChangeHandler(); Automation.AddStructureChangedEventHandler( AutomationElement.RootElement, TreeScope.Subtree, new StructureChangedEventHandler(handler.HandleEvent)); handler.Start(); // Start Notepad to get a structure change event using (AppHost host = new AppHost("notepad.exe", "")) { } Assert.IsTrue(handler.Confirm()); Assert.IsNotNull(handler.EventSource); Automation.RemoveStructureChangedEventHandler( AutomationElement.RootElement, new StructureChangedEventHandler(handler.HandleEvent)); }