Forum Discussion

qanhd's avatar
qanhd
Occasional Contributor
15 years ago

How to catch Windows dialog of 'App Not Responding' and handle appropriately?

Is there anyway to get an event where 'Windows dialog for not responding app' appears? And then handle those appropriately?



I have created a handle for 'Unexpected Window' event but it didn't catch this dialog from Windows.



Any help is greatly appreciated.



Thanks,

Anh

10 Replies

  • Hi,



    You can check whether your application is responding by using the IsProcessResponding function posted here.
  • qanhd's avatar
    qanhd
    Occasional Contributor
    Thanks for the reply.



    But I was hoping to know WHEN the stop responding occurs, not having to constantly checking IF it occurs.



    I am using 'Freeze Diagnostics' feature and specifying app that might stop responding, It seems to work (continuing our automation test though an app has stop responding). But is there anyway to know which app that was so we can fail our test case appropriately?



    Thanks,

    Anh
  • Hi,



    By using Freeze Diagnostics, you can catch the error it posts to the log when the tested application hangs. Create a handler for the OnLogError event and process the message Freeze Diagnostics posts there (see the "About Events and Event Handling" and "OnLogError Event" help topics).
  • qanhd's avatar
    qanhd
    Occasional Contributor
    Does TestExecute use this settings too?
  • Hi,



    Yes, TE uses all functionality of TC projects it executes.
  • mp's avatar
    mp
    Occasional Contributor
    hi Jared,



    you write:



    By using Freeze Diagnostics, you can catch the error it posts to the log when the tested application hangs. Create a handler for the OnLogError event and process the message Freeze Diagnostics posts there (see the "About Events and Event Handling" and "OnLogError Event" help topics).



    question:

    is the only way to access currently posted logs by first exporting them ? i have tried over and over accessing the current log with constructs like these:



      Set LogItem = Project.Logs.LogItem(0)

      Set LogData = LogItem.Data(0)

      Set Row = LogData.Rows(0)

      ...



    this is your description of handling current logs:



    Get current log items



    since i want to parse the current log from the OnLogError routine, this seems like very much overhead, exporting the log at each error. is there no other way ?



    thanks and best regards

    martin











  • Hi Martin,



    If you need to parse the contents of the current log, the only way to do this is by exporting the log to XML. The current log is not in the project's log collection at run-time, it is in memory, and TC generates its contents. That's why it is not accessible via Project.Logs.



    As for OnLogError, I'm not quite sure why you would need to parse the entire log in its handler because all the information on the error currently posted is available there, and it allows you to process all errors as they occur without missing them. Do you need to do something specific which requires exporting the log in OnLogError? And what do you do there (maybe, there's a more efficient way to do the same)?

  • Hi Martin,



    If you need to parse the contents of the current log, the only way to do this is by exporting the log to XML. The current log is not in the project's log collection at run-time, it is in memory, and TC generates its contents. That's why it is not accessible via Project.Logs.



    As for OnLogError, I'm not quite sure why you would need to parse the entire log in its handler because all the information on the error currently posted is available there, and it allows you to process all errors as they occur without missing them. Do you need to do something specific which requires exporting the log in OnLogError? And what do you do there (maybe, there's a more efficient way to do the same)?

  • mp's avatar
    mp
    Occasional Contributor
    hi Jared,



    thanks for your response.

    the use case for me would be exactly as was stated by the original post: i.e. to be able to parse the current log for messages of tested apps that are not responding anymore and be able to kill them explicitly or simply stop the execution of the current test.



    you write:



    As for OnLogError, I'm not quite sure why you would need to parse the entire log in its handler because all the information on the error currently posted is available there, and it allows you to process all errors as they occur without missing them.





    exactly that would be my question: HOW do i access/parse the text of the currently written log error ? actually, i don't want to read the entire log, only the current log item that led to the error. is there a way/command to do that ?



    it's just that sometimes an application returns a specific window with an error that i would like to catch and handle differently than all the rest. e.g. write something into a file when this happens etc.



    thanks & best regards

    martin
  • Hi thought I’d try to help.



    As soon as any error occurs (except for errors which occur due to script/code being wrong) Test Complete goes to the onLogError handler to see how you would like to deal with the error.



    As far as my knowledge goes LogParams  (the information about the current error) is passed to the event error and you can use



    http://support.smartbear.com/viewarticle/28074/

     http://support.smartbear.com/viewarticle/32762/



    to deal with errors.



    So for example i think this should work:



    If(LogParams.MessageText == “Message that is usually posted to the log when the error occurs”){



    //deal with this type of error



    }





    http://support.smartbear.com/viewarticle/31750/