Bagikan melalui


Editing Coded UI Tests Using the Coded UI Test Editor

The Coded UI Test Editor lets you easily modify your coded UI tests. Using the Coded UI Test Editor, you can locate, view, and edit your test methods, UI actions and their associated controls in the UI control map.

Coded UI Test Editor

UI Test Edito

The Coded UI Test Editor toolbar offers the following commands:

  1. Find helps to locate UI actions and controls.

  2. Delete removes unwanted UI actions.

  3. Rename changes the names for test methods and controls.

  4. Properties Opens the Properties Window for selected item.

  5. Split into a new method lets you modularize the UI actions.

  6. Move Code adds custom code to your test methods.

  7. Insert Delay Before adds a pause prior to a UI action specified in milliseconds.

  8. Locate the UI Control identifies the location of the control in the UI of application under test.

  9. Locate All helps to verify control property and significant changes to the application’s controls.

Key Tasks

Associated Topics

Open a coded UI test in the Coded UI Test Editor: You can view and edit your Visual C# and Visual Basic based coded UI test using the Coded UI Test Editor. Using the Coded UI Test Editor can be quicker and more efficient than editing the test methods code using the Code Editor.

Modify UI action properties and their associated control properties: Using the Coded UI Test Editor, you can quickly locate and view all the UI actions in your test methods. When you select the UI action in the editor, the associated control is automatically highlighted. Likewise, if you select a control, the associated UI actions are highlighted. When you select either a UI action or a control, it is then easy to use the Properties window to modify the properties associated with it.

Remove unwanted UI actions: You can remove unwanted UI actions from your coded UI test using the Coded UI Test Editor. For example, your test might include unintended UI actions, or UI actions that you no longer need to test.

Clarify and cleanup coded UI tests by splitting up its methods: You can split a test method to refine or modularize the UI actions. For example, your test might have a single test method with UI actions in two container controls which might be better modularized in two methods associated with each container.

Move a test method to the UIMap.cs or UIMap.vb file to facilitate custom code: If you determine that one of your test methods in your coded UI test requires custom code, you must move it into either the UIMap.cs or UIMap.vb file; otherwise, your code will be overwritten whenever the coded UI test is recompiled.

Find a control in the Coded UI Test Editor:

You can use the Find button in the Coded UI Test editor toolbar to open the Find and Replace tool in Visual Studio. You can then use the Find control to locate a UI action in the Coded UI Test editor. For example, you can try to find “Click ‘Login’ button.” This can be useful in large tests.

NoteNote
Only the Find functionality is supported in the Coded UI Test Editor. You cannot use the replace functionality in the Find and Replace tool in the Coded UI Test Editor.

Determine where a control in your coded UI test is located in the UI of the application under test: Sometimes, it can be difficult to visualize where controls are located in the UI of the application under test. Using the Coded UI Test Editor, you can select a control in your coded UI test and then view where it is located in the UI of the application it is associated with.

Locate Descendants of a container control: You can verify that all the controls under a container can be correctly located in the UI of the application under test. This can be helpful in verifying search property changes you may have made on the container. Additionally, if there have been significant changes in the UI of the application under test, you can validate that the existing control search properties are still correct.

Add a delay before a UI action: Sometimes, you might want to make the test wait for certain events to occur, such as a window to appear, the progress bar to disappear, and so on. Using the Coded UI Test Editor, you can accomplish this by inserting a delay before a UI action. You can specify how many seconds you want the delay to be.

NoteNote
If you need to ensure that a specific control is available before a UI action, you should consider adding custom code to your test method using the appropriate UITestControl.WaitForControl---() method. For more information, see Making Coded UI Tests Wait For Specific Events During Playback.

See Also

Concepts

Testing the User Interface with Automated UI Tests

Other Resources

Testing the Application with Feature Pack 2