I want to retry same test case 3 times from code itself if any of the keyword fails from below code (e.g. Action1 and Action2 Failed then retry from start or retry test case -Create_Claim_Task ). If my all keywords succeed then I want to exit loop.
Below is my code
Create_Claim_Task
FOR ${i} IN RANGE 5
Action1
Action2
Final_Action
Close All Browser
Exit For Loop If ${i} == 3
Log ${i}
END
Log Exited
*** Keywords ***
Action1
Log action1 Keyword
Action2
Log action2 Keyword
Close All Browser
Close All Browsers
Final_Action
Log action2 Keyword
If I’m understanding it right what you could do is as below:
${action_one_status}= Set Variable ${False}
${action_two_status}= Set Variable ${False}
${final_action_status}= Set Variable ${False}
WHILE not ${action_one_status} and not ${action_two_status} and not ${final_action_status} limit=3
${action_1_status}= Run Keyword And Return Status Action One
IF not ${action_1_status} CONTINUE
${action_2_status}= Run Keyword And Return Status Action Two
IF not ${action_2_status} CONTINUE
${final_action_status}= Run Keyword And Return Status Final Action
IF ${final_action_status} BREAK
END
So if it reaches the final action and succeeds it will break from the loop completely as it would have succeeded with the two actions before (i.e hadn’t failed on its action), if at any point prior to it, so at Action One or Two it will CONTINUE to the next iteration if it fails at any of those points, and the limit of 3 iterations.
@_daryl
Thanks for your input but I want to start entire test case from start , can we call same test case from keyword like go to statement in other language. I want to run same test 3 times if its fails at any point
No problem and apologies I miss understood, I believe this question of some sort has been asked a few times on the forum, just searching and taking the first result which might be helpful in answering your question or a start in the right direction:
Personally not done this myself using the test:retry(value), but seems fairly straightforward