Pause Playback in Coded UI Tests

When playing back coded UI tests you have two ways to add a delay. To add a pause between method calls just call Playback.Wait(). But how do you add a pause between playback of recorded actions? Thats what the rest of this post is about.

To add a pause between playback of recorded actions you have to somehow get a Playback.Wait() into your UIMap.Designer.cs file. As it is generated from UIMap.uitest’s contents you have to edit that file. In UIMap.uitest, find the action that you want to be delayed and add a ThinkTime-Attribute to it. After that regenerate your tests and admire a new Playback.Wait() in UIMap.Designer.cs.

Quite easy and not worth a blog post one would think–two reasons it might take you longer than expected to get this working:

  • Unlike stated in Microsoft’s documentation you specify ThinkTime in milliseconds and not in seconds. Only if you supply a value smaller than one second it gets rounded to a second.
  • I’ve had no luck using NoOperationAction or DelayAction elements in UIMap.uitest. Either of them would allow you to add a commentary about why you need that delay.

External References

  • Microsoft’s documentation of ThinkTime is here.
  • Microsoft’s Visual Studio UI Automation Testing Forum is here.
  • A blog post with information about new features in coded UI testing that will save you a loop or two is here.
Advertisements
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

One Response to Pause Playback in Coded UI Tests

  1. Greg Gum says:

    I was puzzled why Wait(5) was not working and you answered that question.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s