Freigeben über


Writing a Coded UI Test for an International Application

In this blog post we will see how to write a coded UI test for a Hindi application. For this we will start with a simple Hindi 

WinForm application which takes two strings and concatenates them.

 

The first string is entered into the first text box and the second string is entered into the second text box and the result is displayed next to the 'Result' label.

 

For entering the Hindi letters, Hindi inscript keyboard was used. The following methods of inputting hindi input does not work well:
 

  1. Hindi transliteration keyboard
  2. Hindi typewriter
  3. Hindi typewriter (akruti)
  4. Hindi Remington keyboards

 

Now we will walk through the series of steps required to generate a coded UI test for this application.

 

Steps

1. In Visual Studio 2010, click on Test menu and choose New Test

 

 

 

 2. In the Add New Test dialog, choose Coded UI Test and click OK.

NOTE:- You can choose to create a Visual C# test project or a Visual Basic test project.

3. In the New Test Project dialog, change the Test Project name and click Create.

4. In the Generate Code for Coded UI Test dialog, choose Record actions, edit UI Map or add assertions

5. The Coded UI Test Builder will start up.

6. Click on Start Recording button to start the recorder.

Note: There is a slight delay when the recorder starts. Ensure that the button changes to the Pause Recording before recording test steps.

7. Now perform the desired test steps.

 

For the purposes of this tutorial, we are going to test the concatenation of two hindi strings.

 

NOTE: Coded UI Test works on Web (IE 7 & 8), WinForms & WPF apps. I am choosing the above as an application which is straight forward and illustrates the point being made

 

The Test steps are

a. Launch the application Hindi concatenator

b. Type हग in the first text box

d. Type तक in the second text box

e. Click 'Add' button

Note that a text description of actions will be shown in the Recorded Actions window. The Recorded Actions window can be pinned if you want to see the actions being recorded. It will become semi-transparent when you move focus away from it.

 

 

 

8. Click on the Generate Code button and change the name of the method to TestAdd.

 

 

 

9. Now drag the cross-hair and drop it on result field in the concatenator. A blue rectangle is drawn around the selected label control.

 

Click on the Add and Generate button to add this method to the project.

 

 

 

 

 

 

Click on the Add and Generate button to add this method to the project.

16. Close the Coded UI Test Builder by clicking on the X button.

17. The Coded UI Test is now opened within the Visual Studio IDE.

 

NOTE the following characteristics about the generated code.

a. The CodedUITest1 class is tagged with a Coded UI Test attribute.

b. The CodedUITetMethod1 method is tagged with a Test Method attribute.

c. in the CodedUITestMethod1, the methods we created are invoked.

 

18. Note the following in the Solution Explorer.

a. All required references for Coded UI Test are added automatically.

b. 5 files are added to the Test Project

i. CodedUITest1.cs - main Coded UI Test class, Test Methods and Assertions.

ii. UIMap.uitest – XML Representation of the UI Map (a container of UI Controls) and the recorded actions.

iii. UIMap.Designer.cs - Code generated for the UIMap

iv. UIMap.cs – empty file where UIMap customizations may be added.

iv. UserControls.cs - Specialized classes representing various UI Controls referenced in the Test.

 

19. Right-click inside the Coded UI Test Method and choose Run Tests

20. The code is compiled and then the test is run.

21. All actions recorded earlier will now be played back.

22. After the test run is completed, right-click on the Test Run and choose View Test Results Details.

 

 

 

Note:

 

References:

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