Forum Discussion

Everseeker's avatar
9 years ago

How do I catch an error popup that appears... Asynchronously?

So, moving along in my tests, All is going swimmingly,  Hamsters are running full tilt, data is being processed, when suddenly...


That's not good.

ESPECIALLY since the application sometimes continues running for a while... (This error pops on any issue, sometimes the issue is from a SP that is running asyncronously)


I need to create a kind of... "Watch" process... If this window EVER appears, stop what you are doing and handle it

THe Object itself shows as 2015-07-24_8-49-14.png

And, for further "Identification", I can "look" at this:2015-07-24_8-30-10.png

Before I go into what I need to do IF I encounter the object... I need to know HOW to "Catch" it

  • AlexKaras's avatar
    9 years ago



    Is the same Application Error unexpected window opens for the other tests ?

    If it is not (i.e. some other unexpected window is opened) then you can identify the window in the event handler and either process it or not.

    If the same unexpected window is displayed but you like to handle it in one test and do not handle in another test, then the simplest solution might be to set some Temporary Project Variable (see help for more details) as a flag of whether or not the window must be handled.

4 Replies

  • I must say, this error window is really kind of handy...

    When it shows up, if you hit <ALT>, a little question mark appears... If you click THAT, you get Ye Olde Error Dump.


    And, if you click the "Submit recurring issue" the Dev team gets a nice Error email, filled with all of the above, and more...

    So, I REALLY want to be able to work WITH the devs on this.

    • AlexKaras's avatar
      Champion Level 3



      Is this window modal? I.e. does it block any further user actions in the UI until closed?

      If it is, than I would recommend to:

      a) Create the OnUnexpectedWindow event handler for your test project (see help for more details on this as I can't provide you with the link at the moment, sorry); and

      b) Insert UI-related actions in your test code when appropriate. E.g. use window.Activate after opening a new window or when switching to the already opened one; use control.Click before entering data into controls (if this does not create problems); use tab.Click when switching between tabs on the form instead of setting some their property; etc.

      The case here is that if this error window is opened at the moment when you try to execute some UI-related action, this action will be blocked and OnUnexpectedWindow event will be triggered. In the handler code for this event you will be able to process the error window and make a decision of should the test be stopped or not.

      • Everseeker's avatar

        Your recommendation... well... almost works... I Think :)


        Here's what I did:


        1. created a Script based test... Unit1

        It opens a couple pages, gets this error, and exits


        2. Set up an Event handle for the OnUnexpectedWindow event... pointed the wizard to Unit1

        perfect. It created this:


        Sub GeneralEvents_OnUnexpectedWindow(Sender, Window, LogParams)


        I stuck things in there to identify the error, do some things that could "fix" it, then gracefully exit....

        life was grand... Sort of.


         But then (Cue dramatic Music)


        3. (New session)

        I created a Keyword test...Test1

        It too opens a couple pages, and exits

        I do NOT run the event handler thing for THIS Keyword test...

        I do not WANT to use that handler here.

        Perhaps I will, in the future. But I do not especially want to, yet


        However, what I want does not matter... because, as luck would have it, this Keyword test(For an entirely different area) pops an unexpected window of its own AND the event triggers, and my event handler (FROM A DIFFERENT SCRIPT) runs. The resolution for the error in the other test is NOT correct...


        I guess that Unit1 needs to ??? Turn the event handler on & off programaticly?

        or ???

        I honestly am a bit annoyed at TestComplete "ASSUMING" that I want to blend my tests.....