UI UX Design Services Dayton, Ohio

Coded UI Automation ToolCoded UI Test (CUIT) is a relatively new automation tool in the software market. It was made available as part of the Visual Studio 2010 update. The product has undergone a lot of enhancements and its new version has been released as part of Visual Studio 2013. Software code can be easily reviewed and debugged in Visual Studio, it also has an IntelliSense code completion feature, which helps in generating code faster. Coded UI automation tool is supported by high level programming languages such as C# and Visual Basic .NET.

Software testers revere the high level language support offered by Coded UI automation tool. It is a known fact that software testers prefer learning VB Script (used by QTP [presently known as UFT] and Test Complete automation tools), as it is easy compared to other languages such as Java, C# or VB.NET. Software testers who have knowledge of writing code in object-oriented programming language (OOPL) especially prefer using Coded UI automation tool.

Why Coded UI is a Smart Choice in Test Automation

The robust capabilities of Visual Studio and Team Foundation Server (TFS) have made them hot favorites among software developers. Developers utilize both these tools to create superior software applications. The combined usage of TFS, Visual Studio and its testing tools augments the process of agile development. Here are few reasons why Coded UI tool is a preferred choice for software testers:

  • Software testers and Developers can work using the same tools/language, which enables them to collaborate effectively.
  • The Coded UI automation tool supports both web and windows projects, as both C# and VB.NET are known for their robustness.
  • The element identification mechanism is a powerful feature in Coded UI.
  • Coded UI strongly supports Synchronization. The Playback Engine supports features such as ‘WaitForReadyLevel’, ‘WaitForControlExist’ etc., it makes the test execution stop till UI Threads or All Threads are ready.
  • Automation tests can be run on remote machines with the help of ‘Tests Agents’.
  • Coded UI supports AJAX controls.
  • Descriptive Programming is another impressive feature supported by Coded UI tool, which allows software testers to automate scenarios based on object properties. There’s no need to wait for the user interface to record/assert scenarios.
  • Coded UI allows developing an extensive test suite and performing tests in local environments.
  • Using Coded UI with layered framework, automation teams can develop sophisticated tests.
  • Utilizing Log4net.dll, software testers can log the results and capture exceptions in an effective manner.

How to Begin with Coded UI Testing

Here’s the process to commence automation testing using Coded UI tool.

Software Requirements

Software testers can use either Visual Studio Premium or Visual Studio Ultimate to create Coded UI tests. Visit the MSDN website to obtain more information on supported configurations and platforms.

Coded UI Framework

The below illustration depicts the Coded UI Framework

Coded UI Framework

Let’s scrutinize the above framework illustration to interpret it effectively. As depicted in the above illustration, the App code folder contains all the reusable functions, which are used to write test scripts. Let’s assume that a software tester is automating a Gmail application, the Login, Home page and Logout code are written in different functions such as Login(), Homepage() and Logout() under ‘Gmail’ class. While writing the test scripts, software testers can reuse the above functions. Here’s the code to achieve the above functionality.

 public class CodedUIScripts
 public void HomePageVerification()
 GMail gmail = new GMail();

The ‘App Code’ folder includes recorded scenarios, customized code and database connections as well. Log4net.dll is used to log the PASS/FAIL/ERROR results during test execution. The Configuration Settings file includes Environment/Browser/Account settings. ‘Property Provider’ helps in providing information on specific properties supported by each control i.e. ‘Browser Services’ for browser specific operations such as launch browser, navigate to specific URL etc. The ‘Technology Managers’ abstraction layer helps abstract rest of the code from various technologies. The last layer is a technology specific layer, which deals with web, win forms etc.

Understanding the Technology

Below is the overview of Technology Managers (shown in the above illustration).

Microsoft Active Accessibility (MSAA)

MSAA is a COM based technology, which was integrated into Microsoft Windows Operating System starting with Microsoft Windows 98. MSAA is utilized to automate Win Forms applications.

User Interface Automation (UIA)

The UIA was introduced with Microsoft .NET framework.


The web implementation is utilized to access the DOM in a web browser. It supports Internet Explorer and cross browser playback in Chrome and Firefox, utilizing some additional plugins.

Getting Started with Coded UI Automation

Let’s create a sample solution using Coded UI tool.

Create a Solution
  • Open Visual Studio:
    • File -> New -> Templates -> Visual C#/Visual Basic -> Test -> Coded UI Test Project.
    • Assign a name to the project and save it in a desired location.

Image depicting create solution in Coded UI tool

Recording a Scenario
  • Click on ‘Test’ menu and select ‘Generate Code for Coded UI Test’ and then click on ‘Use Coded UI Test Builder’.

Image depicting record scenario

  • You will be prompted with a ‘UIMap-Coded UI Test Builder’ screen to record/assert the scenario:
    • The recorded steps will be displayed by pressing Alt + S or by clicking on the icon available beside the record button.
Coded UI Test Builder ScreenTo Assert a Scenario
  • Assertion feature is available in Coded UI Test Builder. Normally, checkpoints are called as Assertions in Coded UI, an Assertion can be added based on the property of an element.
  • In the ‘UI Control Map’, we can add, delete or rename controls. Once the assertion is added, we can set the comparison operator and the value to compare.
  • We can add an Assertion (check point) by clicking ALT + U or by clicking on the Assertion icon available on the Coded UI Test Builder.

Add Assertion Screen

Features of Coded UI Test Automation Tool

  • Microsoft Visual Studio stores application related objects in its own UIMap repository. Software testers can move/copy all the Recorded/Asserted scenarios to either custom classes or to UIMap class.
  • Testers can prepare scenarios based on captured objects or by using code first (descriptive) technique.
  • CUIT Editor was initially made available in Visual Studio 2010 (feature Pack 2) onwards, which allows editing UI Map.
  • Software testers can select any object to view its properties and can also change search properties or expressions.
  • They can also expand the recorded actions and view the steps. Options are also available to delete the steps, split a bigger method into multiple methods. However, software testers cannot add a new step to an existing action.

Windows Application Automation Testing

If you are keen to learn about Code First Approach and Windows Application automation testing without making use of the UI Map. I would recommend you to refer our blog on Windows Application automation testing, which offers good insights on handling and performing operations on Windows application controls.


The default UIMap tends to become heavy if testers add a number of large methods to it. In order to overcome this issue, testers can add ‘non-default UIMap’. However, testers need to take care of calling methods after recording actions with the Coded UI Builder.

Build the Solution and Run the Tests

After the ‘Test Methods’ are written, build the solution to view the automated test scenarios under ‘Test Explorer’.

How to Run Test Case(s)
  • Select the required Test case(s) and then right click and select ‘Run Selected Tests’.

After the test run is complete, all successful test cases will show under ‘Passed Tests’ category and failed test cases will show under ‘Failed Tests’ category. The tests which were not executed will remain under ‘Not Run Tests’ category.

Coded UI Tool - Test Explorer Screen

Coded UI Test Class and Test Method
 public class CodedUIScripts
 public void HomePageVerification()
 GMail gmail = new GMail();
UI Map Methods
public void Login()
 #region Variable Declarations
 HtmlEdit uIUserNameEdit =this.UIWelcomeMercuryToursWWindow.UIWelcomeMercuryToursDocument.UIUserNameEdit;
 HtmlEdit uIPasswordEdit = this.UIWelcomeMercuryToursWWindow.UIWelcomeMercuryToursDocument.UIPasswordEdit;
 HtmlInputButton uILoginButton = this.UIWelcomeMercuryToursWWindow.UIWelcomeMercuryToursDocument.UILoginButton;
 // Type 'User Name' in 'userName' text box
 uIUserNameEdit.Text = this.LoginParams.UIUserNameEditText;
 // Type 'Password' in 'password' text box
 uIPasswordEdit.Password = this.LoginParams.UIPasswordEditPassword;
 // Click 'Login' button
 Mouse.Click(uILoginButton, new Point(25, 10));
UI Map Fields
[GeneratedCode("Coded UITest Builder", "11.0.60315.1")]
public class LoginParams
#region Fields
public string UIUserNameEditText = "Mercury";
public string UIPasswordEditPassword = "FEpfJNHdTZmsLaNM/cpYZhaIgTOTKjC4";


The Coded UI automation tool is a highly powerful and robust test automation tool from Microsoft. Software professionals revere the high level language support offered by Coded UI and its ease of usage. Being a Microsoft product, software professionals can expect excellent support and constant upgrades. Coded UI is being widely accepted by the software tester’s community across the globe.

This blog was updated on 30 July, 2015 to provide information and include a link of Windows Application Automation Testing blog. 

Naveen Varadaraju

Naveen Varadaraju is Sr. Software Test Engineer at Evoke Technologies. His area of expertise is automation testing, he is highly proficient in using various testing tools, including Coded UI and Unified Functional Testing (UFT). Naveen closely follows emerging trends in the software testing domain.