Working over automoted testing controls with UITestControl Methods

Author: Alfonso Alarcón

In the next link of MSDN you can find mandatory methods in order to work with speficic properties of the controls under test by automated testing:


How to get menu elements from the parent element

Author: Alfonso Alarcón

In Coded UI Test solutions of visual Studio (Enterprise, Ultimate or Premium versions) is recommendable to optimize efforts avoiding recording actions when a large numbers of elements must be recorded. Therefore, the best option is to get the Coded UI controls from the parent control and to get from it all the children items using  Add a new control to the UIMap tool (see

For example in a typical calculator the menu bar has a set of menus (View, Edit and Help) the strategy to follow is to get only the squared UI Control and from it get both all the menus and related items of each menu.


In the next class is provided how to click in an element of a menu. Therefore, if you want to click for example in the Programmer item of the menu bar the key point is to use GetChildren():

        public static WinMenuBar MenuBar;
        private static Dictionary<string, WinMenuBar> objDict = UiTestMenuBarDict.UiTestWinMenuBar();
        public static void MouseClickSubMenuItems(string menu, string subMenu, string dictKey)
            MenuBar = objDict[dictKey];

            foreach (WinMenuItem item in MenuBar.Items)
                if (item.FriendlyName == menu)
                    foreach (WinMenuItem subMenuItem in item.Items)
                        if (subMenuItem.FriendlyName == subMenu)

How to get UI Controls with Coded UI Test Builder without recording actions

Author: Alfonso Alarcón

One of the most powerful technologies to work with automated testing is the Coded UI Test Builder included in the Enterprise version of Visual Studio 2015 (previously Premium and Ultimate Visual Studio versions) [1, 2]. It presents the well know recording tool to get automated testing but other procedure can be follow to save efforts and improve the maintenance in large automated testing projects. It follows the Add a new control to the UIMap tool. In the next a set of points to get UI Controls with this tool are presented:

  1. The first step is to create a Coded UI Test solution in Visual Studio
  2. In the created solution go to uitest (right button) and Edit With Coded UI Test Builder


  1. Here, it is show the two principal tools to work with Visual Studio in automated testing:
    1. Recording tool marked with A in the next screenshot.
    2. Add a new control to the UIMap tool marked in B in the next screenshot. As commented, the strategy presented here is based on get UI Controls with this second. To work with it you must apply it on the desired control in the UI of the application or web.


  1. Next add the captured data to the UI Control Map by means of To Add a new control to the UI Map marked with C in the next screenshot. Use the option copy to clipboard (D in the screenshot) to get the text of the UI Control and apply it in the code later.


  1. In UIMAP.uitest go to UI Control Map where the details of the UI control are shown.


A last comment, the name of the stored UI Control can be changed. As the number of stored UI Controls is increased the difficulties to understand the meaning  of them increases. Therefore it is a best practice to rename UI Controls in function of its content.