Forum Discussion

katreenmei_nare's avatar
katreenmei_nare
Occasional Contributor
11 years ago

Capture exact unexpected window name on error log

Good day.



On the error log, only "an unexpected window appeared" item will be shown on the test log.



Is there any way that TestComplete will automatically capture the exact name of the window that unexpectedly appearedr?



Thank you.
  • simon_glet's avatar
    simon_glet
    Regular Contributor
    Hi Katreen,



    Create an Event Handler and add something like this:





    function GeneralEvents_OnUnexpectedWindow(Sender, Window, LogParams)

    {

      LogParams.Locked = true;

     



      // Post an error message about unexpected windows to the test log

      Log.Message("Unexpected window");



      // Post an image of the whole screen to the test log

      Log.Picture(Sys.Desktop.Picture(), "Unexpected window", "This image was added to TestLog from the GeneralEvents_OnUnexpectedWindow procedure")



     

        Window.Close();  

    }





    Sincerely
  • katreenmei_nare's avatar
    katreenmei_nare
    Occasional Contributor


    Hi Simon,



    Thank you for your reply.

    However, I'm afraid that will not fully work in my case because I don't know what exact possible error screens the system will encounter during playback.



    For example, an error message screen stating that there is no internet connection.


  • simon_glet's avatar
    simon_glet
    Regular Contributor
    In our case (desktop application) as we take a picture of the whole desktop (line 10)  the log will contains any possible unexpected window.



    If you are talking about the balloon notifications generated by the Windows taskbar that I never had to deal with, sorry.