Scaling up your CUIT UI automation for real world projects

One of the complaints that we heard often from Coded UI test users in Beta2 was that the coded UI tests could not scale up to large projects. The single UI map that contained all the UI elements and recorded methods would quickly become unwieldy and confusing to use. To address that problem, we introduced the concept of multiple UI maps in coded UI tests in the VS 2010 RC.

You can now add more than one UI map to a test project containing Coded UI tests by just using the Project level menu of Add new itemà Coded UI Map to add new UI map to the test project. If you need to edit the UI map, you can simply right click on the .uitest file node in Solution Explorer and load the UI map file in the Coded UI test builder. From here, you can add new methods/controls, edit controls, rename controls etc.

Add a new Coded UI map

So, why do we recommend using multiple UI maps in your test project? When your application under test is be a large app with over 1000 forms or web pages, using CUIT in the default single UI map format can result in overloading the UI map and make it cumbersome. Splitting the single map into multiple ones provides the following benefits:

  • Each UI map is logically separated and associated with a smaller construct of UI – easier to understand and maintain
  • Each tester can individually work on a separate UI map and checkin code when they are ready without interfering with other testers working on other portions of the UI
  • Easier to scale UI incrementally by adding new UI maps as compared to conflict resolution using a single UI map

Now, how do you determine when to create a new UI map? If you have a complex composite UI control set doing a logical operation or an independent aggregate of controls that you can navigate to separately and perform specific operations on, it is recommended you create a UI map for that. Eg: a registration page for a new user in a website, a dialog in a winforms app or a WPF app etc. You can have multiple UI maps per single UI aggregate also – for example, for a wizard, you can either create one UI map per wizard page or create a single UI map for the entire wizard, depending on how complex the interactions with the wizard and it’s child controls are.

Note that in many cases, the top level window(TLW) of your application is constant(if your app is a website, the TLW will correspond to the browser window or if it is a winforms/WPF app, the TLW will be the main application window). Since CUIT searches for controls beginning with the ancestor control, which in most cases is the TLW, the instance of the TLW will repeat across multiple UI maps leading to duplication of controls. This can give rise to problems like having to make duplicate fixes across UI maps when the TLW search props change or perf problems when switching between UI maps since the TLW will have to searched again, once per UI map. In order to resolve this, you can equate top level windows across UI maps in the test code using the CopyFrom() API. We’ll see an illustration of how to do this in the walkthrough in my next post here:

Comments (4)
  1. Nagaraj says:

    Hi Anu,

    Please let me how fast forwarding of codedui/manual testing works for asynchronous calls. whether it supports or not.

    [Anu] Yes, it does. Just add a waiter to the next action

    Thanks & Regards,


  2. Nagaraj says:


    I also one more query.

    For web applications if standard controls are not used does test manager recognises them viz. third party text box created using com.

    [Anu] Depends on the automation accessibility support in the 3rd party control. Try it and let me know if you hit issues

    Pls let me know..



  3. Nagaraj says:

    Hi Anu,

    I have doubt regarding CodedUI test.

    I have created a codedui test for Calculator app with Add,Subtract,Multiply and Divide functionality. I have recorded a scenario where I will open the app then enter values in txbox1 and txbox2 and hit on ADD button.It works fine.Now I used UIMap.cs file to change the searchproperty for ADD button so insted of ADD I said "Subtract" for Name property.So when I ran the test it clicked on subtract button it works as expected. So I have one more textbox i.e third one "txbox3" sameway I changed the search property of txbox1 so that it should enter values in txbox3. So i created a method in UIMap.cs file and called in codedUIMathod. But it is throwing an error  "SetProperty of "Text" is not supported on control type: Window". So kindly let me know whether we can alter the properties of testboxes.

    public void ChangeButton()


    this.UICalculatorWindow.UIAddWindow.UIAddButton.SearchProperties[WinButton.PropertyNames.Name] = "Subtract" ;

    this.UICalculatorWindow.UITxbox1Window.SearchProperties[WinWindow.PropertyNames.ControlName] = "txbox3" ;

    this.UICalculatorWindow.UITxbox1Window.UITxbox1Edit.SearchProperties[WinEdit.PropertyNames.ControlName] = "txbox3" ;


    [Anu] The easiest way to do this to record the set property action on the text box directly. Perhaps your control is not editable

  4. naresh says:


    I need more information on Code UI Test, Here my query's are

      1) working with Multiply UI Maps

       2) how to run multiple test case one bye one

      3) how to integreate multiple UI maps into single.



    [Anu] This blog answers all your qs, Naresh 🙂

Comments are closed.

Skip to main content