Coded UI Test

In the previous post, you saw how the Manual Testing has been made really easy with Camano. As I had mentioned, when you run through a manual test case for the first time, the Microsoft Test Runner (MTR) captures your UI actions as an “action log”. You have seen how this allows the tester to “fast forward” through her testing in subsequent runs, where MTR simply plays back the “action log”. This “action log” is also useful when it is time to turn a manual test into an automated test, which, for example, can be used as part of a build verification suite.

Let’s consider the case where you are testing the Windows Calculator and have a test case that checks some basic functionality of the application. You now want to automate the test, add validations, and run this regularly as part of a build cycle. Your goal is to ensure that there are no regressions in this part of the application. This is where the “Coded UI Test” feature of the VSTS 2010’s Test Edition comes into play.

Coded UI Test allows you to generate an automated test from a published test case in Team Foundation Server. You just point to the test case on a Team Foundation Server and code will be generated for the test. Magic!!! Not really. Visual Studio simply takes the action log  stored for the manual test and converts it into code. (Coded UI Test is a new test type in Visual Studio). I really like this simplicity in converting any manual test into an automated test!

As an example, the “action log” for the manual test case noted above may look like:


When you convert this into a Coded UI Test, the actions noted above are translated into the following snippet of code.


Now, in the manual testing case, the tester of course was able to verify in person that the above test case generates the result 9. Coded UI Tests allow to simply add such validations directly into the code. This is as simple as right-clicking the position in the code where you want to add the validation, bringing up the “UI Control Locator”, selecting the control and it’s property in the application that you want to add validation for, and letting the tool add the assertion. Here are some screen shots for the “UI Control Locator”, and the screen to select the control property to validate.



You drag the crosshair of the control locator onto the result box of the application. Click on Add Control and Show Properties. Select the “DisplayText” property and hit OK. The following code gets generated for you.


Presto! You have successfully created a Coded UI Test and you can now run it.

By the way, while in this case  we have generated the automation code from an existing manual test, you can also start from scratch and use a action recorder to record the actions you want translate into code. Here’s a screen shot of the action recorder


Of course, you may not want to use any of the tools, but want to create Coded UI Test right at the API level.  For this, you can use the new Microsoft.VisualStudio.TestTools.UITesting API set to directly reference UI controls, perform actions, and validate properties.

It is also important to point out that code can be generated into any of the .Net languages. In the first version we will support code generation into C# and VB.Net. We hope this further helps break down the walls between developers and testers, where the automation engineers or developers can use the standard .Net languages for test automation code generation and there is no new scripting language to learn.

You will also be happy to know that, continuing with our theme of full integration of features across the life cycle, Coded UI Tests are fully integrated with Team Foundation Server (if you are using one).

  • You can publish the results of a Coded UI test run to Team Foundation Server. A bug may be created in Team Foundation Server from the results of a Coded UI Test run.

  • You can attach the Coded UI Test to a Test Case (see screenshot below). You can then run this automated test from Camano.

  • You can create a data driven test case sourcing its data from a test case on Team Foundation Server.


This then completes a quick overview of the “Coded UI Test” feature. To reiterate again, you will use this feature when:

  • You want to add validations to your test

  • You want to create an automated test and run it as part of the build cycle

  • You want to customize your automated tests to improve its resilience

I am also including a link here for a step-by-step tutorial that walks you through the creation of a Coded UI Test – Tutorial on creating a Coded UI Test

Most of you are familiar with test automation and use it in some form or other in your projects. What you think of this new feature? Are there specific details you’d like me to elaborate in future posts? I am very interested in hearing from you – do leave a comment.

Comments (33)

  1. ブログ記事の紹介です。Visual Studio Team System 2010 の新機能である Coded UI Test についてわかりやすく紹介されている記事があります。 Amit Chatterjee’s

  2. Thank you for submitting this cool story – Trackback from DotNetShoutout

  3. bob53050 says:

    Thanks for providing this information Amit. We worked with this in the CTP and it shows great promise 🙂 Can you please go through the running of tests against a selected data source. It is not functional in the CTP so we are curious to see where this is planned to go 🙂

    • Bob Hanson
  4. Hi Bob – we do support the running of a Coded UI test against a data source. Mathew Aniyan, talks about this in his blog post – This post shows an example of data driving through a CSV file, but we support database sources as well.

  5. Steve Lange on I told you it was coming!  "Team System Big event" The Public Sector DPE

  6. Vasili I. Galchin says:


        1) Can the Team Test system be used to test legacy(already existing) VB6 code?

        2) Does Team Test have a way to simulate manipulating a legacy VB6 GUI, e.g. filling in dialog boxes, push GUI buttons, etc?

    Regards, Vasili

  7. Hello Vasili – thank you for your question. For the VS 2010 release we will validate the GUI testing feature (record and playback) for Web, WinForms, and WPF platforms. However, the technology should work fine for VB6 as well – do give it a shot with our CTP bits. Likewise you will be able to generate a CodedUI test for VB6 applications as well – the generated code though will be in VB.Net or C# languages.

  8. Vasili I. Galchin says:

    Hi Amit,

       Thanks for your generous answer. What is CTP bits? Is it possible to get a pre-release of 2010 to try out the Team Test UI functionality?

    Very kind regards, Vasili

  9. Hi Vasili – CTP stands for "Community Technology Preview". You can down load the last CTP bits for VS 2010 at –

  10. Vasili I. Galchin says:

    Thank you, Amit!

    Regards, Vasili

  11. Nelinger Eran says:

    Hi Amit,

    Thanks for the intresting article.

    I’m working for a few years on automation of web based application with HP (former Mercury) QTP.

    I was wondering how well the "UI Control Locator" know to identify a dynamically generated UI element in HTML?



  12. Vasili Galchin says:

    Hi Amit,

      How are you?

      When will Team Test 2010 be available for alpha? for beta? for release?

    Kind regards,


  13. I am very excited proud and proud to introduce the new testing features you’ll find in dev10. In addition

  14. Tom says:

    Hello Amit,

    Does to CodedUI test work for infragistics controls?



  15. Mandar Sawant says:

    Can I generate a load test using the Coded UI Test ?

  16. Carrie says:

    Is it possible to customize the error messages that display in the Test Results? Is it possible to add log messages that indicate test steps?

  17. Roman Maxymchuk says:

    Guys, i have an issue with the "UI Control Locator" not "seeing" any components which are nested inside the MS WPF tab controls. Is this a known issue?

  18. srini says:

    coded ui testing not capturing the popup and the sub menus of the ui

  19. Carlos says:

    In Working with Coded UI Tests, how would you manipulate the values of cookies?  We can do this with the current API we leverage for functional testing but haven’t found a way to do so with the Coded UI framework.  Similarly, the current api we use exposes and http proxy such that in a test method, we can run blended tests at the UI or protocol (http) levels.  Is this possible with coded UI tests?

  20. Hari says:

    I like this post very much. Very informative and easy hands on for newbies like me. In addition I have seen significant changes in Beta 1 and Beta 2 code, do you have any plans to republish this post with Beta 2 changes?

  21. Pavan says:

    how to use multiple CSV files for a single TESTMETHOD

  22. Prasad says:

    Can any one explain the pros and cons of Coded UI and QTP

  23. cybtron says:

    Hi Amit,

    I have three testing environments for our application. The environments are Dev, QA and Prod, all three having the same application but different urls.

    I recorded test against the Dev environment and  they are failing against QA and Prod. How can I resolve this. Thanks,

  24. cybtron says:


    I have three testing environments for our application. The environments are Dev, QA and Prod, all three having the same application but different urls.

    I recorded test against the Dev environment and  they are failing against QA and Prod. How can I resolve this. Thanks,

  25. keshava says:

    hi Amit, This is keshav .as i am new to coded ui testing i am not aware of how to start with could u please give some linksregarding the features o CUI .earlier i worked with QTP will it help in coded ui test.expecting reply soon.

  26. keshav says:


    I had a list of issues could you please aresolve it.Please find the link Below

  27. keshav says:

    Does CUI supports Descriptive programming ? can any one please give some links in simple examples.please have a glanca on below link

  28. vaidy says:

    Hi All,

    I have visual studio 2010 installed but i am not able to see the coded UI automation in that.

    Please help.



  29. Jeremy Tyriaux says:

    Nop. Infragistics controls doesn't allow to acces to their field

  30. Anil Bhatt says:

    Hi Amit,

    really good page on codedUI. Do you know if I can use this tool for automation test related with word/excel addins? Word does not expose the ID's of the control in the addin windows? So is there any work around to achieve this through codedUI?

  31. autoeng says:

    hi amit

    how do I add a column inside the excel file to the textbox ?.

  32. Cato the Elder says:

    I am blogging about hand-coded CUIT over at  My post on DRY page objects is here:…/keep-your-page-objects-dry