Forum Discussion

marinb's avatar
marinb
Contributor
7 years ago

Suppress browser crash error?

Our tests occasionally fail with a browser crash. Chrome crashes a tiny bit more often due to the still somewhat unstable chrome plugin, but IE also suffers from the occasional crash.

 

This gets reported as an error in the log "the <browser>.exe process has crashed".

Is it possible to suppress this error or have it not show up as an error? It most often appears when we try to gracefully close browsers, so technically it's just a 'hiccup' and won't fail other tests.

 

All our functions are run in a try/catch construction, but the crash is not caught unfortunately and still force us to analyze the logs because the 'tests have failed'.

 

TLDR: a way to have a browser crash not appear as error, failing the test suite.

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    While I am second to cunderw with the suggestion to either check browser settings or contact Support to give guys a chance to correct the problem if it is on the TestComplete's side, the plain answer to your question is : yes, this is possible.

    Create the OnLogError error handler (see documentation for more details) and suppress the required error message within it.

     

    > All our functions are run in a try/catch construction

    While this may be a reasonable approach in development world, in the world of TestComplete this is seldom required.

    The case is that try/catch handles only language runtime errors like division by zero, null-pointer access, etc.

    But most problems in TestComplete tests are not runtime but 'logical' problems that are not a problem from the language runtime point of view but are problems from the point of view of actions over test objects. For example, process crash or absence of some window is not a runtime problem (all at all, TestComplete has no idea of what are you checking. It is quite possible that the goal of your test is to check that process crashes after some actions or that some window does not exist), but it is a logical problem because you are explicitly referring to some object and this means that the object must exist.

    Note, that there are two ways to reference objects in TestComplete. I call them explicit and implicit.

    Explicit reference is when you address object directly in your test code. For example: Sys.Process(...). Explicit reference means that you expect that the object must exists at this point and thus its absence is treated as a logical error and is reported to test log. Note one more time - this is a logical problem but not the runtime one and thus it is not handled by try/catch.

    Implicit reference is when you try to get an object but it is possible that the object may not exist at this point. In this case you must use WaitXXX() method in your test code. For example: Sys.WaitProcess(...). .WaitXXX() methods do not log the error if the sought for object does not exist but instead they return an empty stub object with the .Exists property set to false, so that you can check in your test code whether or not the sought for object was found and act accordingly.

     

    • marinb's avatar
      marinb
      Contributor

      Thank you for the reply! To elaborate on our situation:

      - Each test step is run in a try/catch so that we gracefully capture the error and move on to the next step. Not every function. It's more like a shell around executed functions.

      - We have some functions that gracefully try to stop browsers and terminate the process if browser.close does not work. We do this in a loop, so those nasty multiple iexplore background processes are also killed, since they often screw up target frame identification. I notice we haven't set the TabProcGrowth  registry yet, so maybe that helps.

       

      What I really try to do is indeed simply catch the particular 'browser has crashed' error. But the event handler seems a little complex. There is no event.browsercrash event handler of some sort it seems and onerrorlog seems to do stuff 'before the error is posted to the log' and not suppress the error.

       

      What would be the jscript code to prevent a specific error from appearing?