Forum Discussion

JonoW's avatar
JonoW
Occasional Contributor
13 years ago

Help required with handling of unexpected windows

Hi,



I have a couple of issues that I could really use some help with.



I'm running my automated tests as part of the build on our automated build server. 

Our tested app sometimes crashes, or at least windows is reporting that it's crashing when it shuts down. This results in a dialog box being displayed (by windows 7) asking whether I'd like to "Debug" or "Close Program". All of the TestComplete tests may pass successfully, but if this dialog is not closed, then the next and successive builds will fail, because the pesky dialog has some kind of flag set on the build / binaries folder, which prevents the build server from deleting/recreating it - even though all the files in the directory are deleted, including the tested app executable etc. It's all gone - empty folder that's somehow still in use by this dialog.



I can't seem to catch this with unexpected window handling in TC... only on the build server do I get the close/debug dialog.



When the app "crashes" during shutdown on the development PC, I just get a message saying something like "The program has stopped responding, please wait" and that is closed automatically by windows a few seconds later.



Question: What else can I do, is there a better way to catch this dialog on the build machine? When should I put the check for it in my tests? I guess right at the very end would be best... but I can't generate it (the same dialog) on my TC dev machine (build server only has TestExecute), so I can't map it in name mapping etc.





We did have a problem a while back where our appilcation might sometimes hang on startup - then the next build would fail because the file in use and can't be deleted problem occurred.

My solution to this was to run our Cleanup Utility (which looks for any of our app's processes that are still running and kills them) at the end of the test run, or if the test run should fail (I think I put it in the OnLogError event handler).

I also made this utility run before trying to start our tested app, just in case there were any of its processes running somehow.



This seemed to work ok for a while, but now for some reason - even though only one instance of this app should be allowed to run at once - I end up with two instances of this app running. I'm currently looking into that.



I've put a check in by doing the following

if (Sys["WaitProcess"]("CleanupUtility")["Exists"])

    ExitButton.ClickButton();



Where CleanupUtility is the app and ExitButton is the exit button on the app's form. 



This sometimes seems to work ok, but I'm now seeing errors in my test log - The "&Exit" window is invisible and thus cannot be activated. 



Question: Can I just run that waitprocess check a few times in order to catch multiple instances of this cleanup utility?





Any advice you have would be great. Thanks in advance.



3 Replies

  • Would the OnUnexpectedWindow event in TC help? Handle closing the window when it pops up within the event that is responding to its presence?
  • ArtemS's avatar
    ArtemS
    SmartBear Alumni (Retired)

    Hello Jono,


    I can't seem to catch this with unexpected window handling in TC... only on the build server do I get the close/debug dialog.


    What else can I do, is there a better way to catch this dialog on the build machine?


    There seems to be an issue related to interaction of TestComplete and the Windows Error Reporting system (which shows the "Debug" or "Close Program" dialog you spoke about) under Windows7. I have reproduced this behavior and registered it in our database. We will investigate the issue and inform you about our results. Thank you for reporting it.


    Question: Can I just run that waitprocess check a few times in order to catch multiple instances of this cleanup utility?




    Yes. You just need to change the "if" condition to "while":





    while (Sys["WaitProcess"]("CleanupUtility")["Exists"])


        ExitButton.ClickButton();





    This would close all instances of your cleanup utility.

  • ArtemS's avatar
    ArtemS
    SmartBear Alumni (Retired)
    Hello Jono,



    The ability to handle error reports generated by the Windows Error Reporting system will appear in the next major release of TestComplete.

    Sorry for the inconvenience.



    Best regards,

    Artem