Чтобы издеваться над тем, где есть какое -то окно , когда появилось тестовое приложение (как показано выше), которая покажет какое -то окно , когда появилось информация , когда появилось тестовое приложение (как показано выше), которая покажет какое -то окно . Нажал. < /p>
Так выглядит мой тест: < /p>
Код: Выделить всё
[Fact]
public async Task Can_Identify_An_Information_Window()
{
//ARRANGE
// My service that will start the app:
await _myUIAutomationService.StartAppAsync("PathToMyTestApp");
//Find the app window
var appProcess = Process.GetProcessesByName("MyTestApp'sProcessName")[0];
var appWindow = AutomationElement.FromHandle(appProcess.MainWindowHandle);
//Find the buttons on the app window:
var buttons = appWindow.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button));
//Grab the button that will show the information window and click it to show the information window:
foreach (AutomationElement button in buttons)
{
if (button.Current.Name == "Open Info Window")
{
// click it to open the information window:
var invoke = (InvokePattern)button.GetCurrentPattern(InvokePattern.Pattern);
invoke.Invoke();
}
}
//ACT
// My service that will get the status of the app including the windows it's showing:
var appstatus = await _myUIAutomationService.GetAppStatusAsync("MyTestApp'sName");
var informationWindow = appstatus.InformationWindows[0];
//ASSERT
Assert.NotNull(informationWindow);
}
Код: Выделить всё
Automation.AddAutomationEventHandler(InvokePattern.InvokedEvent,
button,
TreeScope.Element,
OnInvoked);
// Handler for information window showing button invoke event:
private void OnInvoked(object Sender, AutomationEventArgs E)
{
// The control never reaches here.
}
Любая справка/направление будет высоко оценено.
Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/687 ... nteraction