Trying to catch a timeout without failing the test

Im trying to find a way to catch a Timeout to run a keyword again. There is a specific keyword that is currently bugged and will take some time to fix so I am looking for a short term robot framework solution in the mean while. Currently when the keyword is first called it will hang but every time after it works fine. So I’m currently looking to have it timeout and then attempt again but there is currently no catch other than “Run Keyword If Timeout Occurred” which only works on teardowns (which would prevent my test cases from running). Below I have a basic version of how I would want it to work (I know it doesnt because “Run Keyword And Ignore Error” does not catch timeouts. Im hoping someone knows a workaround for how to catch a timeout or how to prematurely fail a hanging keyword without the use of [Timeout].

Start Keyword
{status} Run Keyword And Ignore Error Call Broken Keyword Run Keyword Unless "{status}" == “PASS” Call Broken Keyword

Call Broken Keyword
[Timeout] 10 sec
Broken Keyword

I just noticed how messed up the format for my example was so here it is again:

Start Keyword
${status}    Run Keyword And Ignore Error    Call Broken Keyword
Run Keyword Unless    "${status}" == "PASS"    Call Broken Keyword

Call Broken Keyword
[Timeout]    10 sec
Broken Keyword

I think you need to look at Wait Until Keyword Succeeds

1 Like

Sadly I already have and it does not work for my issue. The retry interval is for after the keyword fails and “Wait Until Keyword Succeeds” also doesnt catch timeouts if I were to use it. So either I dont use the timeout and it remains hanging or I use it and “Wait Until Keyword Succeeds” fails on the first attempt.

There are several ways to use it. By a counter or timeout.

But I think you need:

`Wait Until Keyword Succeeds     The Keyword that manages the Failing Keyword`

I am currently trying to use a keyword to manage the failing keyword. It is a library keyword that I cannot modify at this time so I cant add a counter to it. If I add [Timeout] to the managing keyword “Wait Until Keyword Succeeds” does not attempt it again by robot framework design as can be seen by the documentation from the keyword " All normal failures are caught by this keyword. Errors caused by invalid syntax, test or keyword timeouts, or fatal exceptions are not caught."

Hi Disen,
you need to return two values.
${status} ${err} = Run keyword And ignore error Broken KW
This will return:
${status}= ${false}, ${err}=<raised err message>
And your test does not fail. And based on err decide what to do next.