Forum Discussion

MattS's avatar
MattS
Occasional Contributor
9 months ago
Solved

Catch fail in keyword Execution

I am attempting to take a list tests that have been created, loop through it, catching any that fail to be logged in a report at the end. 

 

When I execute the loop:

 

Try{ run KeywordTest}

catch{ error}

 

Most errors are not caught. For example, a tested object does not exist on the page, so it errors out and stops execution, rather than catching and continuing.

 

Is there any method that would allow me to catch such errors and proceed?

 

  • The alternative options are to build your own exception handling system, to deal with the appropriate exceptions that you throw - not so easy!

     

    If you have a project suite, with many projects and tests, I find using the project settings, continue running on error, works fine. 

3 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    A test that fails, does not throw an exception. Unless you are throwing an error e.g.

    throw new Error("Something went wrong");

     

    If you want the test to continue after an error, then you need to change your project settings, see Project Properties - Playback Options

    • MattS's avatar
      MattS
      Occasional Contributor

      Is there anything that would allow me to control this more granularly than at the project level? Or can that only be applied to everything?

       

      I'd like to continue to stop on error in most scenarios. 

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    The alternative options are to build your own exception handling system, to deal with the appropriate exceptions that you throw - not so easy!

     

    If you have a project suite, with many projects and tests, I find using the project settings, continue running on error, works fine.