Share via


How to: Insert a Delay Before a UI Action Using the Coded UI Test Editor

By using the Coded UI Test Editor, you can open a coded UI test for viewing and editing. 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.

Note

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.WaitForControlXXX() method. For more information, see Making Coded UI Tests Wait For Specific Events During Playback.

Opening a Coded UI Test in the Coded UI Test Editor

Follow these steps to open an existing coded UI test for editing in the Coded UI Test Editor.

To open a coded UI test in the Coded UI Test Editor

  1. In Solution Explorer, locate UIMap.uitest in your test project.

  2. Right-click UIMap.uitest and select Open.

    -or-

    Double-click UIMap.uitest.

    The coded UI test is displayed in the Coded UI Test Editor. You can now view and edit the coded UI test. For more information, see Editing Coded UI Tests Using the Coded UI Test Editor and How to: Edit a Coded UI Test Using the Coded UI Test Editor.

Inserting a Delay Before a UI Action

Follow these steps to insert a delay before a UI action in your coded UI tests.

Insert delay before a UI actionDelay added with 5 seconds

To insert a delay

  1. In the UI Action pane, expand the test method that contains the UI action that you want to insert a delay before. Select the UI action.

  2. Right-click the UI action and click Insert Delay Before.

    A delay is inserted and highlighted before the selected UI action with the following text: Wait for 1 seconds for user delay between actions.

  3. If the Properties window is not displayed, press F4. In the Properties window, change the value for the Delay property to the desired number of milliseconds.

  4. On the Visual Studio toolbar, click Save.

    The updates to the test method are saved in the UIMap.Designer file.

See Also

Tasks

How to: Edit UI Action Properties Using the Coded UI Test Editor

Concepts

Making Coded UI Tests Wait For Specific Events During Playback

Other Resources

Editing Coded UI Tests Using the Coded UI Test Editor