Search code examples
pythonrobotframeworkkeyword

Robotframework: The use of Wait Until Keyword Succeeds


Am a noob at Robot, i would like to use the Wait Until Keyword Succeeds with my keywords but its always passed even when it should not. So i am trying to figure out what is the value of the return of my keyword that controls passed/failed. As an example: My keyword

def check_num(num):
    if num == 1:
        return True
    else:
        return False

Am calling:
Wait Until Keyword Succeeds      5 times      2 s       check num       0

Am expecting it to run 5 times with 2sec pauses and fail at the end, but its always green. If its not True/False that should be used, can you please tell me what is expected? Thank you.


Solution

  • Returning False isn’t considered a failure. A keyword only fails if it throws an exception.

    def check_num(num):
        if num != 1:
            raise Exception(f”{num} is not 1”)
    

    For more information see Reporting keyword status in the robot framework user guide.