Forum Discussion
I'm going to suggest that you don't take the errors out. You may miss other failures by doing that.
In your case 1, if Button 2 doesn't exist but it was supposed to be there for that user, you wouldn't get notified.
For case 1, I would use If Object Exists and possibly Last Operation Result to find the button.
https://support.smartbear.com/testcomplete/docs/app-objects/common-tasks/checking-existence.html
https://support.smartbear.com/testcomplete/docs/keyword-testing/basic/result.html
I would also wonder what happens if you execute these steps one at a time. If this works, perhaps you're actually having a timing issue in the test that's causing the failure.
In your case 2, it looks like you are combining waiting for the window in order to test it and waiting for the window to go away. Here I suggest that you use the wait to do just the current test. So, wait for Window1 to appear then do the test. Next, if you want to actually check that Window1 is gone, do another wait for that. Otherwise, go on to waiting for Window2 to appear and do its tests.
Hope that helps.
The best way to do what you are looking for is, as Marsha_R, not to avoid getting errors logged, but to do a better job of detecting object existance. That's what the WaitNNN methods are for. And, if those methods aren't working, then Find, FindChild, FindAllChildren, etc., are a close second.
So, on your first example, what are you doing to check for existance of button2? Are you using a WaitNNN or a Find call? Could you post the code your using? For that matter, you say WaitNNN isn't working for you... could you post what you tried when you used that? Perhaps you're missing something obvious.
On your second example, instead of waiting for "Visible", wait for "Exists". The "Find" function returns an empty stub which has VERY little in the way of properties. One it DOES have is "Exists" and it's set to False. From the help:
If no object matching the search criteria was found, the
Findmethod returns a stub object that only contains theExistsproperty equal to False. So, you can check theExistsproperty value of the returned object to determine whether the search was successful.
Visible would work if the removal of the screen is simply a matter of removing visibility. But if the object actually "disappears" from the object browser, Exists is a better check. So, change that second code to
wait_time = 2
while Sys.Process("app").Find('AutomationId', '123', 100, True).Exists:
if wait_time > 6:
Log.Error('123 screen is displayed for too long')
break
else:
wait(wait_time)
wait_time += 2
Now, concerning WaitNNN not working... if you are using WaitNNN and checking "Visible", that could be your problem as well. Like the Find function, if the WaitNNN method times out, what is returned is an empty stub with "Exists" set to False.