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.
- 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.