【问题标题】:Coded UI tests not correctly finding my control编码的 UI 测试未正确找到我的控件
【发布时间】:2015-02-03 06:25:51
【问题描述】:

我正忙于对应该是非常基本的编码 UI 测试进行概念验证。

我的应用程序是 Winforms,我有一个允许您登录应用程序的表单。

这里有 2 个控件,分别称为 _textUsername 和 _textPassword。

为了简化整个事情,我希望回放能够双击用户名文本字段 (_textUsername)。

但是,在播放过程中选择了 _textPassword。

我尝试调整搜索条件以包含控件名称,但它根本找不到控件并失败。

我的问题很简单:我的表单上有 2 个控件:_textUsername 和 _textPassword,UI 编码测试似乎总能找到 _textPassword,我怎样才能让它找到另一个文本框?

【问题讨论】:

    标签: c# user-interface coded-ui-tests


    【解决方案1】:

    尝试手动对控件进行编码。您可以使用 UI 测试生成器来查找搜索属性。 inspect.exe 也很有用。有时属性不是您所期望的。

                // Controls
            WinWindow logonWindow = new WinWindow();
            WinEdit _textPassword = new WinEdit(logonWindow);
            WinEdit _textUsername = new WinEdit(logonWindow);
    
            // Add search properties and configurations
            logonWindow.SearchProperties[WinWindow.PropertyNames.Name] = "Main Window Name";
            logonWindow.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);
    
            _textPassword.SearchProperties[WinEdit.PropertyNames.Name] = "Password";
            _textPassword.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);
    
            _textUsername.SearchProperties[WinEdit.PropertyNames.Name] = "Username";
            _textUsername.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);
    
            // Identify each control
            logonWindow.DrawHighlight();
            _textPassword.DrawHighlight();
            _textUsername.DrawHighlight();
    

    【讨论】:

      【解决方案2】:

      这在 DevExpress 中被证明是客户端应用程序和测试运行程序代码之间的错误版本。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-02-05
        • 2013-11-29
        • 2014-11-12
        • 1970-01-01
        • 2023-03-23
        • 2015-07-08
        相关资源
        最近更新 更多