Forum Discussion

MichaelMcFarlan's avatar
MichaelMcFarlan
Contributor
14 years ago

Preventing crashes when running testcomplete

I've got a pretty big project suite that tests lots of different aspects of the software we release. I test this project on our software before we release it and I occasionally will get an error early on in the script that causes the whole project to fail. I'm wondering if there's any simple methods / techniques / whatever to allow test complete's projects to be more robust. Usually these errors are simple things like an error message box (or sometimes exceptions not being handled as they should). The only way I can think of would be adding checks between almost every line of code and that isn't a viable option. If there was some sort of OnError event that would be amazing because I would almost always just want to close whatever dialog popped up and go on to the next project item.



I'm not looking for a clear-cut solution really, just if anyone has any hints or pointers on how to do this they would really be appreciated.





Edit: I do know about using try/catch/finally, I might try to work that more into the scripts.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    There are "OnUnexpectedWindow" and "OnOverlappingWindow" events that you can assign handlers to.  This might help with what you're dealing with.
  • Thanks, both of those look useful and I'm not actually sure which one I need, mostly because I haven't been able to get them to work.



    What I'm trying to do: I'm trying to make it so that when my program produces an unexpected error message box it will simply close the message box. The message box is the default one windows always uses for errors and warnings and whatnot.



    I've tried setting up event handlers for "OnTimeout" and "OnUnexpectedWindow" using the default function names and parameters. Inside of each of these all I have is a Log.Message("we got here!"). I have the projects options "Auto-wait, timeout" set to 30000 (30s) and I've waited at least that with nothing happening. The project settings for "On unexpected window" have the "Click on focused control", "Press Esc", "Press Enter", and "Send WM_CLOSE" checked. However, none of those appear to be happening as the message box still just sits there no matter how long I wait. The test complete icon that shows what the script is doing just says the project name and sub-project name without any indication of waiting for anything. If I manually close the message box testcomplete jumps right in where it left off/



    If anyone has any idea what I'm doing wrong please let me know, or if you need any additional information. I'm going to go try doing some of this in a new test project and see if I can't get it to work any better.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    OnUnexpectedWindow will only fire if you try and execute some sort of task, event, etc., against an object that lies behind it.  So, if all you're doing is waiting at that point, it won't fire.  Now, if you try and click on a button that lies behind the window, TestComplete will see the "Unexpected Window" and attempt to perform whatever task you have set up to perform.
  • The waiting is not intentional, only a result of the error message box showing up and test complete not responding. I tried replicating this in a new project and in the new project testcomplete sent WM_CLOSE to the error message two seconds after it popped up, which now leaves me with no idea why my actual project isn't working seeing as I've triple checked to make sure all the project settings are the same.



    I feel like this is kind of diverging from the original post, but I guess that's how it goes. In a nutshell, my problem now is that testcomplete isn't acting at all on unrecognized windows, it just waits.. and waits and then waits some more. I'll be testing this more to see if I can get it working some how.
  • ArtemS's avatar
    ArtemS
    SmartBear Alumni (Retired)
    Hello,



    In a nutshell, my problem now is that testcomplete isn't acting at all on unrecognized windows, it just waits.. and waits and then waits some more.


    Do you perform the test under Windows 7 or Vista, and the unrecognized windows are generated by the Windows Error Reporting (Werfault.exe) service? There is a known issue of TestComplete's not reacting to Werfault dialogs. This misbehavior will be fixed in the next major release of TestComplete.



    If this is your case, you can either try handling the application exceptions via Debug Services, or temporally disable the Windows Error Reporting service during tests.



    Best regards, Artem.