Coded UI Test (CUIT) - Convert Manual Test Case to Code using Visual Studio 2010

Posted by: Gouri Sohoni , on 5/22/2011, in Category Visual Studio
Views: 80347
Abstract: In this article, we will discuss another way of creating Coded UI Test CUIT i.e. by using the recording created with the help of Microsoft Test Manager 2010 in Visual Studio 2010.

In our last article Coded UI Test (CUIT) using Visual Studio 2010 we discussed the architecture of Coded UI Test and how CUIT can be created by recording the actions and adding assertions. In this article, we will discuss one more way of creating CUIT, i.e. by using an existing action recording.

To create an action recording, we need to first create a Test Case and execute it manually with the help of Microsoft Test Manager 2010. Test Case is a new work item added with Team Foundation Server 2010. Test Case comprises of steps, steps can have actions and expected results. We will now start by creating a Test Case by using Microsoft Test Manager 2010 (MTM). The main difference between working with Visual Studio 2010 and MTM is that with MTM, we are always working in a connected environment. We are always connected to TFS 2010 when working. However with VS 2010, we can work only on the client side (without connected to TFS) if required.

In this article, we will see the following:

  • How to create a Test Case
  • Execute it using Microsoft Test Runner
  • Record actions
  • Convert these actions to its code equivalent by using Visual Studio 2010
  • Execute test from VS
  • How to associate automation back to test case.


Step 1: Start Microsoft Test Manager 2010 from the Visual Studio 2010 list of features. MTM 2010 gets automatically installed with VS 2010 Ultimate version. There is a separate installable for Microsoft Test Professional 2010 too. MTM connects to TFS as follows:


Enter the TFS name in the textbox and click on Add button.

Step 2: The list of available collections and respective projects from the server will be shown after connecting to the Team Foundation Server 2010. The 2 process templates supported with TFS are Agile and CMMI. The screen looks as follows:


We can select Connect now after selecting the project name. Here we can see 3 collections in TFS VS2010 with the named DefaultCollection, Demo Collection and DemoWithReports and many projects in DefaultCollection. Each created collection creates a database in turn in SQL Server 2008.

Step 3: Once the project is selected, we can select an existing test plan or add a new one. All the testing related artifacts will be associated with the test plan


Step 4: You can view the 4 tabs in Testing Centre namely Organize, Plan, Test and Track. Select Organize tab > select Test Case Manager from it and then select New Test Case. Enter following details for the test case:



Step 5: Now that we have created test case and added steps to it, let us execute the test case with the help of Microsoft Test Runner.


The screen for execution looks as follows. The left hand side shows the steps and the expected result, while the remaining portion is where actual execution can be done. We will execute the test by using default setting for data adapters.



Step 6: Now that the test has been successfully executed, let us convert the recorded steps to its code equivalent by using Visual Studio 2010. Start VS 2010 > select test project created in previous example and add Coded UI Test template to it.


Select the radio button for using existing recording. The query window will appear as follows:

cuit-manual-query Provide either the work item id or execute query to find the test case which has the recording and select it.

Step 7: The code gets added as follows.



Step 8: Part of the code added in UIMap.Designer.cs looks as follows:

cuit-def-code-manualrecording We can view two of these methods which can be seen from previous step.

Step 9: The added CUIT method can now be executed from Visual Studio 2010. Let us open the work item for test case and specify the code for the Associated Automation tab.


As you can observe, the .cs file gets associated and the Automation Status also changes.

Step 10: After changing the work item of type test case by specifying, we can even execute this automated test case from Microsoft Test Manager. The prerequisite for this kind of execution is that the Test Agent must be running in the Interactive Process mode and not as Windows Service. This is required as there are some interactions with the desktop. Secondly the computer on which the Coded UI Test is running, cannot be locked.


In this article, we discussed another way of creating CUIT i.e. by using the recording created with the help of Microsoft Test Manager 2010. In the next article, we will discuss some variations with CUIT like adding multiple UI Maps and also how the CUIT editor can be used.

This article has been editorially reviewed by Suprotim Agarwal.

Absolutely Awesome Book on C# and .NET

C# and .NET have been around for a very long time, but their constant growth means there’s always more to learn.

We at DotNetCurry are very excited to announce The Absolutely Awesome Book on C# and .NET. This is a 500 pages concise technical eBook available in PDF, ePub (iPad), and Mobi (Kindle).

Organized around concepts, this Book aims to provide a concise, yet solid foundation in C# and .NET, covering C# 6.0, C# 7.0 and .NET Core, with chapters on the latest .NET Core 3.0, .NET Standard and C# 8.0 (final release) too. Use these concepts to deepen your existing knowledge of C# and .NET, to have a solid grasp of the latest in C# and .NET OR to crack your next .NET Interview.

Click here to Explore the Table of Contents or Download Sample Chapters!

What Others Are Reading!
Was this article worth reading? Share it with fellow developers too. Thanks!
Share on LinkedIn
Share on Google+

Gouri is a Trainer and Consultant on Azure DevOps and Azure Development. She has an experience of three decades in software training and consulting. She is a graduate from Pune University and PGDCA from Pune University. Gouri is a Microsoft Most Valuable Professional (MVP)  - Developer Technologies (Azure DevOps), Microsoft Certified Trainer (MCT) and a Microsoft Certified Azure DevOps Engineer Expert. She has conducted over 150 corporate trainings on various Microsoft technologies. She is a speaker with Pune User Group and has conducted sessions on Azure DevOps, SQL Server Business Intelligence and Mobile Application Development. Gouri has written more than 75 articles on Azure DevOps, TFS, SQL Server Business Intelligence and SQL Azure which are published on and You can connect with her on LinkedIn.

Page copy protected against web site content infringement 	by Copyscape

Feedback - Leave us some adulation, criticism and everything in between!
Comment posted by Kavitha on Wednesday, November 16, 2011 6:40 AM
In the Step:6 how to add the Coded UI Template,please help me on this
Comment posted by Naresh on Friday, January 6, 2012 12:01 AM
Hi Gouri,

i have created coded ui testing using VS2010,how can i configure these testing for ruuning auotmatically one by one in TFS server.

Comment posted by Gouri Sohoni on Friday, April 13, 2012 12:11 AM
Hi Naresh,
Sorry for delay in reply. You can configure these tests to run automatically using Microsoft Test Manager MTM, please follow the link for creating and using associated automation and creating a physical environment with MTM from
Comment posted by Naveen on Friday, April 20, 2012 1:51 AM
Hello Gouri,

Can you please share startup tutorials for codedUI biggners. I have worked lot on performance using VSTS however codedUI is new for me and want to explore more on this area.

Please help.

Comment posted by Gouri Sohoni on Tuesday, April 24, 2012 1:46 AM
Hi Naveen,
Start up videos can be seen from
Comment posted by Naveen on Wednesday, April 25, 2012 5:50 AM
Thanks Gauri.
Comment posted by lakshmi on Wednesday, June 20, 2012 1:58 PM
hi gouri

is it possible to convert the ui coded test in vs to mtm

Comment posted by Gouri Sohoni on Friday, June 29, 2012 2:38 AM
Hi Lakshmi,
Please refer to the video for associate automation from
Comment posted by Sara S on Friday, January 18, 2013 8:35 AM
Once you have a recorded action associated to a coded UI test and you update/overwrite the action recording from Test Manager - how do you get the Coded UI test to use the new recording??
Comment posted by Sara S on Friday, January 18, 2013 8:46 AM
Once you have a recorded action associated to a coded UI test and you update/overwrite the action recording from Test Manager - how do you get the Coded UI test to use the new recording??
Comment posted by Sreeya on Monday, June 3, 2013 3:11 AM
I have created CUIT from existing test case recording, now that the requirement has changed. I want to update test case. How should i make those changes refelct in the corresponding CUIT.

Please help.
Comment posted by Gouri Sohoni on Monday, June 3, 2013 3:24 AM
Hi Sreeya,

You will have to re-reord the methods where there is change or change the code as per your requirement manually
Comment posted by Matt on Tuesday, September 3, 2013 12:37 PM
I don't hear any audio for the videos on this site ( ).

Comment posted by Gouri Sohoni on Tuesday, September 3, 2013 11:54 PM
Hi Matt,

There is only video, no audio for the .wmv files

Comment posted by Rohit on Tuesday, May 20, 2014 2:15 AM
HI Gouri,

Can I automate Telerik grid controls usinf CUIT?

Comment posted by Gouri Sohoni on Wednesday, May 21, 2014 11:45 PM
Hi Rohit,
This is a list of configurations and platforms supported by CUIT
Comment posted by Sumantra Ghosh on Saturday, October 25, 2014 8:58 AM
Hi All,

This is Sumantra here from howrah,wb.I have been on coded ui testing around 3 years.  I'll be grateful to you if you suggest me how to get detail knowledge on it listed as below.

1. Interview question
2. TFS knowlesge
3. MTM knowlesge

Thank you,