Forum Discussion

ajb's avatar
ajb
Occasional Contributor
10 years ago

Catching and freeing error messages

I have a program that I'm testing that has a pop up that comes up sometiimes. IIf it comes up I have to click a button, if not, I just want ot go by it. I use this construct:

 

'======= MessageArea =======
'Message Information: Is this order revision change?

Set se = FindChildByProperty(te,"FrameName","a",timeout)
If te.WaitWinFormsObject("MessageArea").Exists then

  Call MessageBoxCheck(te,"Is this an order revision change","No",timeout)
End If

This let's me get past this in both cases (the box exists/ the box does not exist) without giving an error and let's me finish this loop through my test. However, it seems to still save that error. I go through my loop again starting at the top with another record. As I go from frame to frame I do an error check:

 

Set se = FindChildByProperty(te,"FrameName","f_amts",timeout)

if Err.number <> 0 then
  log.Error "["&Err.Source&"]:"&Err.Description
  exit sub
end if

 

On the first error check, the test stops and gives a message:

 

  [MessageBoxCheck::WaitWinFormsObject(Name,timeout)]:MessageBox pop-up fails 13:30:14 Normal

 

This is the error that I avoided at the bottom of the loop and has nothing to do with the current check.

So I added this to the bottom of the loop trying to clear the error:

 

if Err.number <> 0 then
  Err.Clear
end if

 

This, oddly enough, gets me past the first frame check but I still get caught on the second frame check with the same error about the MessageBoxCheck.

 

Thoughts? Ideas?