Reputation: 41939
Running Coded UI tests, my tests occasionally fail due to timing issues (control/ HTML element not on page yet).
Is there a "on document ready" equivalent for coded UI tests? Or maybe there's a best practice for handling this issue?
Upvotes: 0
Views: 550
Reputation: 687
Use this to wait for the document to be ready.
this.PageMapWindow.PageMapDocument.WaitForControlReady()
where PageMapWindow and PageMapDocument are names of window and document controls respectively in your UIMap.
Upvotes: 1
Reputation: 321
@AdrianHHH has the right answer however,
Sometimes I noticed that if you have continue on error set to true for each step it tends to skip bits, so try turning that off
Also you could do it the bad way and use
Playback.Wait();
Upvotes: 0
Reputation: 14086
There are several WaitForControl...
methods that can be used. From your question, WaitForControlReady
may be appropriate. The other methods include WaitForControlExist
and WaitForControlNotExist
that monitor the screen waiting until, respectively, a control appears or is removed; plus several other for more complex situations.
For more details see http://blogs.msdn.com/b/gautamg/archive/2010/02/12/how-to-make-playback-wait-for-certain-event.aspx
Upvotes: 3