繁体   English   中英

无法通过属性“名称”找到WinWindow

[英]Can't find WinWindow by property “Name”

我遇到以下问题:

我尝试在不使用Generator的情况下在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;
    }

我要在[...]部分按下按钮。 但是在此之前发生了问题,因为我什至找不到所需的窗口。 无论我使用窗体的标题还是类名,它都会反复引发UITestControlNotFound异常。
我感到我缺少一个非常重要的观点,但是我不知道是哪一个。

我在这里先向您的帮助表示感谢,

SchwarzSkills :)

启动您的应用程序并将其传递到WinWindow

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM