At my company we do a lot of automated web based testing. All of our automated test scripts are written in VBScript. We kept getting errors that said that the object doesnt exist or unable to find the object so for certain objects we started putting indefinate waits on them an example of this:
Set w1 = p1.WaitWinFormsObject("ClientForm", -1).WaitWinFormsObject("MdiClient", "", -1)
It seems to have solved the problem which makes me very happy but, I believe that by the end of the week we will have waits on all of our objects. Does anyone know if this is the best solution or is there another way to handle this. Also, i forgot to mention. yesterday i got an error that said that it could not find ClientForm (see above) why would i get this if i tell it to wait until the object is there? I am new to using test complete so i dont understand a lot about the tool so any help you can offer would be appreciated.
The WaitWinFormsObject is probably your best solution as it forces TestComplete to look for the object. That is actually a "Best Practice" thing, although it is not directly documented as such. Take a look at the following as a brief tutorial on these wait functions:
A couple of suggestions for your specific situation... I would set your Clientform first and then Set a W2 for the MDIClient.
As for the error you got, the syntax you're using is not an "indefinite" wait, but simply just a look to see if it returns immediately. Add a 3rd parameter on your "ClientForm" object for something like 20000. While your form may come up faster than 20 seconds, putting a wait like that in there forces TC to actually wait up to 20 seconds before failing it out. I'd do the same with your MDIClient as well.
Also, before oyu set your MDI client, I would put in some sort of logic like
Set w1 = p1.WaitWinFormsObject("ClientForm", -1, 20000)
if not w1.Exists then
Log.Error('The form did not return in time')
w2 = w1.WaitWinFormsObject("MDIClient", "", -1, 20000)
That will ensure that your forms exist before you start looking for child properties.