An another FAQ asked question about TestComplete is "Why when I check the Exists property of my [Insert UI element here] do I get an error message in the Test Log?". For Example given the code:
If (Sys.Process("MyApp").Window("#32770","Error").Exists) //Error here :( { // Do Something here }
The user wants to check for the error dialog and only do something if it exists, but it is not a failure of the test if the error dialog does not show up (in fact it is a good thing). The #32770 wndclass is a standard dialog wndclass of Windows.
Part of the problem is not understanding, how and where the error message that TestComplete post comes from. So let us breakdown part of the code above and explain what is happening internally in TestComplete (with some simplifications). The part of the code we will examine is "Sys.Process("MyApp").Window("#32770","Error").Exists". Starting from the Sys object, we call the Process method.
Now, hopefully you have a better understanding of why and where the error message is happening. Of course, this does not explain how to check for the existents of an UI element without posting an error. This is accomplished by using a Wait... method. For example, WaitWindow("#32770","Error",-1,5000), this will wait up to five seconds (5000 ms) for the Window. It will return the Window object if found in that time, otherwise it will return a Stub object. The Stub object has one property, which is Exists and is set to false.
BTW, you can return your own Stub object by using the Utils.CreateStubObject() method.
Remember Me
a@href@title, i, strike, u
Copyright © 2003-2008 Falafel Software Inc.
Subscribe to Falafel Blogs
The opinions expressed herein are Falafel's employees own personal opinions and do not represent Falafel Software's view in any way in case they go bananas!