1

I'm using Visual Studio 2010 Ultimate - visual c# - codedUI.

I'm putting together some automated testing for a client (smoke testing, regression testing, etc.) however the application I'm trying to do the test automation for isn't being cooperative. I've automated all of the client's web apps with no issues, but with their desktop application, I can't seem to get any unique identifier between any of the controls.

Here's a sample codedUI recording where I go through a tree structure in the application - I highlight several different items in the list, expand a list, click on an item, browse the window that launches etc.

    /// <summary>
    /// SomeRecordedMethod
    /// </summary>
    public void SomeRecordedMethod()
    {
        #region Variable Declarations
        WinTitleBar uINavigatorTitleBar = this.UISomeRandomCompanyWindow.UINavigatorWindow.UINavigatorTitleBar;
        WinEdit uIObjectdescEdit = this.UISomeRandomCompanyWindow.UINavigatorWindow.UIDw_navigatorClient.UIObjectdescEdit;
        WinClient uICalendar1Client = this.UISomeRandomCompanyWindow.UIMaintainCalendar1Window.UIItemWindow.uICalendar1Client;
        #endregion

        // Click 'Navigator' title bar
        Mouse.Click(uINavigatorTitleBar, new Point(241, 9));

        // Click 'objectdesc' text box
        Mouse.Click(uIObjectdescEdit, new Point(19, 11));

        // Click 'objectdesc' text box
        Mouse.Click(uIObjectdescEdit, new Point(39, 10));

        // Double-Click 'objectdesc' text box
        Mouse.DoubleClick(uIObjectdescEdit, new Point(37, 11));

        // Double-Click 'objectdesc' text box
        Mouse.DoubleClick(uIObjectdescEdit, new Point(20, 11));

        // Double-Click 'objectdesc' text box
        Mouse.DoubleClick(uIObjectdescEdit, new Point(42, 5));

        // Double-Click 'objectdesc' text box
        Mouse.DoubleClick(uIObjectdescEdit, new Point(61, 11));

        // Click 'Calendar [1]' client
        Mouse.Click(uICalendar1Client, new Point(632, 141));

        // Click 'Calendar [1]' client
        Mouse.Click(uICalendar1Client, new Point(671, 200));

        // Click 'Calendar [1]' client
        Mouse.Click(uICalendar1Client, new Point(675, 301));

        // Click 'Calendar [1]' client
        Mouse.Click(uICalendar1Client, new Point(686, 396));

        // Click 'Calendar [1]' client
        Mouse.Click(uICalendar1Client, new Point(686, 544));

        // Click 'Calendar [1]' client
        Mouse.Click(uICalendar1Client, new Point(478, 547));

        // Click 'Calendar [1]' client
        Mouse.Click(uICalendar1Client, new Point(579, 552));

        // Click 'Calendar [1]' client
        Mouse.Click(uICalendar1Client, new Point(579, 552));
    }

Notice the multiple instances of 'objectdesc' and 'Calendar [1]'. Every duplicate occurance is a different control, but the action recording isn't picking that up.

When I try to run the test I obviously get: Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties.

I'm new to test automation in Visual Studio, so I'm not sure what options I have at this point. Any advice would be greatly appreciated.

Thank you

4

1 回答 1

2

对于许多控件来说,new Point(x,y)参数 toMouse.Click()不是必需的,但为具有两个或更多部分的项目提供,例如,可以单击但也有下拉列表的按钮。您显示的代码中的 (x,y) 值表明 Coded UI 所看到的只是一个大控件,即整个日历或整个 uIObjectdescEdit,而不是其中的字段。

我怀疑应用程序使用了一些不支持编码 UI 的自定义控件。从开发人员那里了解应用程序是如何编写的、使用了哪些技术(例如 WPF、Windows 窗体、MFC 等)以及使用了哪些自定义控件。然后对照 Microsoft 编码 UI 网页上的兼容性列表检查答案。如果使用了自定义控件,那么您可能需要向这些控件的作者重复该问题。

于 2013-05-28T16:07:57.207 回答