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.
- tristaanogre9 years agoEsteemed Contributor
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 towait_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 += 2Now, 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.
- Kate9 years agoContributor
Marsha_R wrote: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.
Thank you for your reply.
In my situations it is not as straightforward as you described. I will add some clarification.
As per case 1.
That case is not about the button2 - it is about applicatoion flow.
All buttons are verified in specific tests.
This case is about verification of the screen after clicking button 3. No matter how I get there, but I need to be there.
That particular issue is about signing out. I start all my tests with running the app and signing out to make sure user is not signed in - just in case when signing out from previous test failed (I called the function sign_out_if_needed). I have 2 groups of users - 1 of them will see and click button2, another will not. I don't want to check the button2. My function is expected to handle ALL users to sign out. So I do not want to be notified about button2. It's all about the screen after button3.
As per case 2.
That is the event that happens before each test. I run the app and I see the 'loading' screen. After that there are several different flows - different screens may appear. So before my test starts I cannot and I do not want to wait for a particular second screen (my event should fit any test). I want this loading screen to go (sometimes it takes 2 seconds, sometimes more than 10....)
I will try If Object Exists
- tristaanogre9 years agoEsteemed Contributor
Kate wrote:
Thank you for your reply.
In my situations it is not as straightforward as you described. I will add some clarification.
As per case 1.
That case is not about the button2 - it is about applicatoion flow.
All buttons are verified in specific tests.
This case is about verification of the screen after clicking button 3. No matter how I get there, but I need to be there.
That particular issue is about signing out. I start all my tests with running the app and signing out to make sure user is not signed in - just in case when signing out from previous test failed (I called the function sign_out_if_needed). I have 2 groups of users - 1 of them will see and click button2, another will not. I don't want to check the button2. My function is expected to handle ALL users to sign out. So I do not want to be notified about button2. It's all about the screen after button3.
As per case 2.
That is the event that happens before each test. I run the app and I see the 'loading' screen. After that there are several different flows - different screens may appear. So before my test starts I cannot and I do not want to wait for a particular second screen (my event should fit any test). I want this loading screen to go (sometimes it takes 2 seconds, sometimes more than 10....)
I will try If Object Exists
On case 1 - If you are using the "Exists" check and you're still getting an error, that's where a "Wait" method or a "Find" method would best come into play... some pseudo-JavaScript for you:
//Using Aliases and WaitAliasChild Aliases.myApp.myForm.button1.Click(); if (Aliases.myApp.myForm.WaitAliasChild('button2', 5000).Exists) { Aliases.myApp.myForm.button2.Click(); } Aliases.myApp.myForm.button3.Click(); //No namemapping/Aliases, the code isn't much different for Waitchild //Using VCLObject as an example, you're might be different var myApp = Sys.Process('myApp'); var myForm = myApp.VCLObject('myForm'); myForm.VCLObject('button1').Click(); if (myForm.WaitChild('button2', 5000).Exists) { myForm.VCLObject('button2').Click(); } myForm.button3.Click(); //If you want to use FindChild, demonstrating with Aliases but works the same for non NameMapping Aliases.myApp.myForm.button1.Click(); if (Aliases.myApp.myForm.FindChild(['ObjectType','Name'], ['Button', 'button2'], 2, true).Exists) { Aliases.myApp.myForm.button2.Click(); } Aliases.myApp.myForm.button3.Click();As for your second case... let us know how using "Exists" works for you.