无法通过 属性 "Name" 找到 WinWindow

Can't find WinWindow by property "Name"

我遇到了以下问题:

我尝试在不使用生成器的情况下在 Visual Studio 2015 Enterprise Edition 中创建编码 UI 测试。我想实现按下按钮并查看结果的非常简单的事情。
我的表单不直接是 WinForms,但它是它们的基础。

这是我正在尝试做的事情:

public void CodedUITestTestMethod()
    {
        //1. Step: Log into the program
        LogIntoProgram();
    }

private void LogIntoProgram()
    {
        // Find the Login-Window
        WinWindow loginWindow = GetWindowByTitle("Program - Login");

        [...]
    }

private WinWindow GetWindowByName(string title, UITestControl parent = null)
    {
        // If the Window has a parent, assign it to the window
        WinWindow result = parent == null ? new WinWindow() : new WinWindow(parent);

        result.SearchProperties.Add(WinWindow.PropertyNames.Name, title);

        result.Find();

        return result;
    }

[...] 部分是我要按下按钮的地方。问题发生在这之前,因为我什至找不到我要找的 window 。它反复抛出 UITestControlNotFound 异常,无论我是使用表单的标题还是类名。
我觉得我漏掉了一个很重要的点,但我不知道是哪一个。

提前感谢您的帮助,

施瓦兹技能 :)

开始你的application and pass it into the WinWindow

     var app = ApplicationUnderTest.Launch("C:\Windows\System32\myProgram.exe"
, "%windir%\System32\myProgram.exe");

    WinWindow loginWindow = GetWindowByTitle("Program - Login", app);