Coded UI Test


Microsoft® Visual Studio® Team System 2010 introduces a new Test Template named "Coded UI Test".  It enables users to verify the functionality of their user interfaces. 

image

Coded UI Test is fully integrated into Visual Studio and the new Test Management features in Team Foundation Server. it supports the following tools.

  • Coded UI Test Builder allows users to record test actions and generate code for them. Generated code is re-factored into methods based on user gestures.

image

  • It also allows users to add UI controls to a UI Control Map and generate assertion code on their properties.

image

  • Coded UI Test has excellent integration with Team Foundation Server.
    • Users may generate code based on an action recording created in Microsoft Codename Camano and published to the Team Foundation Server.

clip_image008clip_image010

    • The Results of a test run may be published to Team Foundation Server. A bug may be created in Team Foundation Server from the results of a Coded UI Test run.
    • The Coded UI Test many be attached to a Test Case in Team Foundation Server.

clip_image012

    • Coded UI Tests may be run as part of a Team Build run.
    • Coded UI Test can be generated from Shared Steps created in Camano.
    • Coded UI Test can be data driven with data associated with a Test Case on Team Foundation Server.
  • Microsoft.VisualStudio.TestTools.UITesting API may be used to directly reference UI controls, perform actions and validate properties.

The underlying Action Recording Engine for Coded UI Test is shared with Microsoft Codename Camano.

The following sub-sections provide details on the features supported by the engine.

· Intent-aware, non-intrusive and resilient action recording: Instead of just capturing raw user actions, the engine has been designed to be intent aware. Set of actions are aggregated into equivalent action to provide an intent aware playback.

clip_image014

Additionally, the engine uses smart algorithms to accommodate changes in configurations like window resize/Minimize/Maximize, screen resolution changes etc to provide a resilient playback support.

· Strong UI technology and platform support: The engine supports a wide range of platforms out-of-the box covering thick client applications built with .Net technologies to latest web applications

  • Windows Internet Explorer 7.0 and Windows Internet Explorer 8.0
    • Support for applications written in ASP.Net, php, jsp, asp, Ajax, SharePoint and web 2.0 applications.
  • Win-forms Controls for Microsoft .Net framework 2.0, 3.5 SP1 and 4.0
  • Windows Presentation Framework (WPF) for .Net framework 3.5 SP1 and 4.0

Internally the engine uses features of IEDOM for recording actions on the web applications being tested via Internet explorer. It uses accessibility technologies in Windows to capture actions on AUTs. Specifically it uses Microsoft Active Accessibility (MSAA) for Win-form support and UI automation (UIA) for WPF support. Custom controls that are developed for Win-form and WPF that follow accessibility guideline are also supported.

· In-built sophisticated mechanisms for handling complex UI action recording scenarios

  • Fast Search: In order to be able to playback user actions, the engine must be able to search for the Control that was acted upon. It uses fast search algorithms to quickly identify the controls and take appropriate actions on them.
  • Wait For Ready Mechanism: When playing back an action the engine needs to know that the UI is ready to act on the next action. For example, if the application was navigating to a web page, the engine needs to wait for the navigation to complete before taking an action. The Wait For Ready mechanism provides this support by intelligently detecting the application’s readiness to act on the next action.
  • UI Synchronization: If the user acted on a control (e.g. a mouse click), the engine needs to ensure that the control actually did receive the input. UI synchronization feature provides this support to the engine allowing it to perform a more resilient playback.
  • Ensuring UI is Visible: In a fast-forward scenario, the UI element (e.g. a list box) that needs to be acted upon might not be visible (scrolled our) or hidden behind another window. This feature ensures that the element is visible before taking an action on it.

Extensibility Support: The engine has been designed with Extensibility in mind. We realize that there are scenarios where our default engine will not meet the needs of our customers. These include being able to test applications built on a different or new UI technology (e.g. flash) or certain application domains that require customized action recording support. Via our extensibility APIs


Comments (18)

  1. shweta4feb says:

    Hi Mathew

    Thanks for the help, the calculator application is working fine. Now I am looking on the actual application on which I need to do automation testing using VSTS. In this case, there are some objects whose properties are not identified by VSTS. In QTP there is Smart Identification by which we can forcefully identify properties of any object. Is there anything like this in VSTS also?

    Thanks & Regards

    Shweta

  2. If you record actions with Coded UI Test Builder, we will record with coordinates and you should be able to play back. (but this will not be resilient).

    What is the intent of assigning properties to the objects? Can you elaborate?

  3. danghung30385 says:

    Dear all,

    I have a project with name ProjectA. In the project, I have 2 scenarios (with name: scenario1, scenario2) that need to write automation script. So:

      1. I will created a project with name ProjectA in VS2010

      2. Then I will create two Coded UI Test Builder files with name: scenario1.cs and scenario2.cs

    Could you tell me that I can add more than one Coded UI Test Builder file on a same project? If I can, so how can I control the UIMap.Designer.cs (because I think if I record and generate for scenario2, the recorded script of scenario1 will be lost)

    Thanks and regards;

    Hung

  4. You can right click on  ProjectA and choose Add -> New Item -> Coded UI Test Map. This will add a new uitest file to ProjectA and it will have its own designer.cs file.

    See http://blogs.msdn.com/anutthara/archive/2010/02/10/walkthrough-using-multiple-coded-ui-maps-in-test-automation.aspx

    for a more detailed description on usage of multiple UI Maps.

  5. suneethakanchana says:

    Hi Hung,

    Better to use UI MAp cs file . use the UIMap.cs file to save your modified recorded methods. You can move the modified methods from the designer file to this file to avoid changes being rewritten.

    i guess this will solve your problem:)

    Suneetha

  6. danghung30385 says:

    Thank all your advices 🙂

    @ Suneetha: I’m a beginner in this tool. If you have any project code to make example, could you please send it to me?

    Thanks and regards;

    Hung

  7. Please try out the tutorial here –

    http://blogs.msdn.com/mathew_aniyan/archive/2009/11/05/tutorial-coded-ui-test-beta2.aspx

    In my opinion, this will be easier than reviewing sample code.

  8. suneethakanchana says:

    Yes, this is the best tutorial to start with Coded UI Test.

    Install and Practice it , you can get some familiarity with this tool, for any queries this is the good place to ask.

    HAPPY LEARNING 🙂

  9. cybtron says:

    Hi Mathew,

    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,

  10. Vijay says:

    I am writing an automated test for a WinForms ListView control that has items with several columns of data which must be verified. The problem is that Coded UI is not able to find the individual columns. Coded UI can find each row in the list as a ListItem, however none of these have child controls that correspond to the columns in the ListView control.

    I have also tried  UITestingUtilities posted at blogs.msdn.com/…/useful-set-of-utility-functions-for-coded-ui-test.aspx

    The UITestingUtilities seems like it could be useful, however when I call GetContent on the list or GetColumnValues values on the listitem I get:

    System.InvalidOperationException: The control passed is not a list view control.  [or list view item in the case of the list item]

    I am able to call GetColumnNames on the list (I am able to identify the column headings as separate controls anyway). The ControlType properties are idenitified as List and ListItem, respectively on the controls. The ClassName is WindowsForms10.SysListView32.app.0.33c0d9d.

  11. Thangavel says:

    How to Create a Console Application for CODED UI?

  12. Thangavel says:

    I want to create a Console application from where, references for Coded UI test to be added. I want to run the test from Console Application. Is that Possible?

  13. Nagaraj says:

    Hi Mathew,

    Thank you very much for the valuable info.

    Currently i am trying to automate the testing and below is the error i am facing.

    CodedUI test automated build: when i run automated test in team build i get this error The 'useAgentDefault' attribute is not declared in event log.

    and in build test results below is the error message i got:

    Error calling Initialization method for test class Tailspin.Test.Model.CodedUITest1: Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException: To run tests that interact with the desktop, you must set up the test agent to run as an interactive process. For more information, see "How to: Set Up Your Test Agent to Run Tests That Interact with the Desktop" (go.microsoft.com/fwlink)

    If you are running the tests as part of your team build, you must also set up the build agent to run as an interactive process. For more information, see "How to: Configure and Run Scheduled Tests After Building Your Application" (go.microsoft.com/fwlink)

    I am using the Microsoft VS2010 VPC and trying to run the codedUI test as part of team build. I have changed the test agent from service to process as mentioned in blogs, but still getting this error.

    Help/Info on this would be of great help..

    Thanks in Advance,

    Nagaraj

  14. Nagaraj says:

    Hi Mathew,

    I have one more question.

    Pls let me know whether VS2010 Coded UI test supports record and replay on Ajax based web pages built using Dojo 1.5 and jquery 1.4.2

    Information regarding the same would be of great help.

    Thank you very much in advance,

    Nagaraj

  15. Nagaraj says:

    Hi Mathew,

    Thank you very much for the valuable info.

    Currently i am trying to automate the testing and below is the error i am facing.

    CodedUI test automated build: when i run automated test in team build i get this error The 'useAgentDefault' attribute is not declared in event log.

    and in build test results below is the error message i got:

    Error calling Initialization method for test class Tailspin.Test.Model.CodedUITest1: Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException: To run tests that interact with the desktop, you must set up the test agent to run as an interactive process. For more information, see "How to: Set Up Your Test Agent to Run Tests That Interact with the Desktop" (go.microsoft.com/fwlink)

    If you are running the tests as part of your team build, you must also set up the build agent to run as an interactive process. For more information, see "How to: Configure and Run Scheduled Tests After Building Your Application" (go.microsoft.com/fwlink)

    I am using the Microsoft VS2010 VPC and trying to run the codedUI test as part of team build. I have changed the test agent from service to process as mentioned in blogs, but still getting this error.

    Help/Info on this would be of great help..

    Thanks in Advance,

    Nagaraj

  16. Nagaraj says:

    Hi Mathew,

    Thank you very much for the valuable info.

    Currently i am trying to automate the testing and below is the error i am facing.

    CodedUI test automated build: when i run automated test in team build i get this error The 'useAgentDefault' attribute is not declared in event log.

    and in build test results below is the error message i got:

    Error calling Initialization method for test class Tailspin.Test.Model.CodedUITest1: Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException: To run tests that interact with the desktop, you must set up the test agent to run as an interactive process. For more information, see "How to: Set Up Your Test Agent to Run Tests That Interact with the Desktop" (go.microsoft.com/fwlink)

    If you are running the tests as part of your team build, you must also set up the build agent to run as an interactive process. For more information, see "How to: Configure and Run Scheduled Tests After Building Your Application" (go.microsoft.com/fwlink)

    I am using the Microsoft VS2010 VPC and trying to run the codedUI test as part of team build. I have changed the test agent from service to process as mentioned in blogs, but still getting this error.

    Help/Info on this would be of great help..

    Thanks in Advance,

    Nagaraj

  17. Aravind says:

    Thanks a lot for explaining the basics of Coded UI Test feature.

    Please help me out in resoving this below mentioned Coded UI queries and it's of high priority I want to use CUIT in my forthcoming project.

    1.How to have a common repository to store control IDs (required as part of framework)?

    2.How to handle cases where the control IDs keep changing dynamically?

    3.Do we have any work around to handle cases when control ID’s are not defined?

    4.How a framework can be generated, a dll can be built, shared among all the resources?

    Regards,

    Aravind

  18. Ramya says:

    Hi Mathew,

              I'm trying to automate a web based survey which includes interactive flash file application in it, using Coded UI testing. Does Coded UI testing support tesing on interactive flash files? I'm using Visual Studio 2010 Ultimate. Any suggestions are welcome.

    Thanks in Advance.

    Ramya

Skip to main content