Contiue with next keyword even if previous keyword failed

Hello all,

I have 2 keywords as below:

Wait Until Page Contains Element    'Error element'    timeout= 200
Wait Until Page Does Not Contain Element     'Error element'   timeout=100

i want the test to continue even if the error doesn’t appear on 1st keyword.

I tried below 2 options but it didnot work for me.
option 1:

Run Keyword And Ignore Error    Wait Until Page Contains Element     'Error element'    timeout= 200       
Wait Until Page Does Not Contain Element     'Error element'   timeout=100

option 2:

${Ignore_Error}     Wait Until Page Contains Element     'Error element'    timeout= 200
Run Keyword And Ignore Error    ${Ignore_Error}
Wait Until Page Does Not Contain Element     'Error element'   timeout=100

I have also tried Run keyword and continue on failure which didnot work for me either

Any suggestions?

Thanks in advance.

Hi Vinay,

I think option 2 is not supposed to work. But option 1 should, imho. Without knowing the error message, it is impossible to guess, what did not work. But you asked for alternate suggestions.

Alternative could be:

TRY
    Wait Until Page Contains Element    'Error element'    timeout= 200
EXCEPT     *    AS    ${error}
    LOG    Could not find Error element due to:\t${error}    WARN
    Wait Until Page Does Not Contain Element     'Error element'   timeout=100
END

You may also try the continue-on-failure feature:

*** Keywords ***
Contain Or Not Contain
    [Tags]     robot:continue-on-failure
    Wait Until Page Contains Element    'Error element'    timeout= 200
    Wait Until Page Does Not Contain Element     'Error element'   timeout=100

Best regards,
Markus

1 Like

Hey Markus,
Thanks for the reply. i tried both alternate options you provided. they didnot work
test case is still failing at the first keyword. I want the test to continue even if the below keyword fails

Wait Until Page Contains Element ‘Error element’ timeout= 200