Forum Discussion

KellyWiegand's avatar
KellyWiegand
Occasional Contributor
3 years ago
Solved

How to execute steps or script when test steps fails?

Hi,

I want to do some steps like "click [Enter]" to the web page / browser when the test item is failed.

Then keep run the rest test items 

Is this workable?

 

Thank you!

3 Replies

  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 2 rankChampion Level 2

    Hi,

     

    Just a note to make sure you understand the difference between OnLogError event suggested by rraghvani and try/catch/finally code mentioned by tristaanogre :

    -- OnLogError will handle 'logical' script problems, for example, the click on the object that has zero size;

    -- try/catch/finally will handle runtime exceptions, like an attempt to use null object or divide by zero.

     

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Beyond the event handlers that rraghvani suggests, you could also go the route of using try/catch/finally code.  This is available both in keyword tests and in script code (depending upon your script language).  This will allow you to execute code on exceptions as well as a "finally" block to execute at the end of every test case.