Change your code to use the WaitProcess method (see documentation here).
something like this:
p = Sys.WaitProcess("program", 10000)
Essentially, methods like WaitProcess and other WaitNNN methods, will wait the specified timeout value for the object to be recognized by TestComplete. If it returns within that time, it will return the object itself. If it doesn't return within the time, it returns a "stub" object with the Exists property set to false.
This should be your methodology, actually, anytime you're doing an "exists" test.
I would suggest first examining the error to determine why it failed. If it's a coding problem, keep the error.
If, however, it's a problem being reported as a problem with the application, that indicates, to me, that your handling of such errors within your automation needs to be addressed. I'd suggest using try/catch methodology for whatever script language you are using (available also in Keyword tests) to trap such errors and log them in whatever means you want.
You can also build into your tests such logic with "if <error condition occurs> Log.Warning" to customize how information is logged.
It's the difference, in short, between recording a test and playing it back... and building a test that actually is a test and not just a macro.
In order for the tests to work correctly I must ensure that there is only one version of the application running at a time. This script basically finds out if the application is already running and if it does firstly try to close it nicely and then after a period of time terminate the application.
I do this by finding out if the application exists in the system. Process as suggested in a different thread however most of the time it does not exist and therefor the test fails.
var p = Sys.Process("program");
I get process not found.
I have tried several different ways of doing the above. I did also try using the try/catch methods as you suggested however may not have done so correctly as it still logged an error. I will try this again tommorrow morning.
Have you tried using the find or findchild method ? You need to get the dummy object if the process does not exist. Otherwise, if you are explicitly defining the object, TC will look for it and print an error if it can't find it.
Right great, I think that the WaitProcess Method is what I've been looking for but I won't be able to try it out until tomorrow morning . Thanks for your help and from now on I will use this method if I'm am testing Exists.