Is there a way to implement 'Wait Until Keyword Returns True'

1,394 views
Skip to first unread message

Nikolay Ivanets

unread,
Feb 13, 2014, 10:39:36 AM2/13/14
to robotframe...@googlegroups.com
I'm looking for a keyword similar to 'Wait Until Keyword Succeeds' which will continue execution of the given keyword until it returns True.

It should looks something like:

Wait Until Keyword Returns True | 10 sec | 1 sec | KeywordReturnsBoolean | args

Kevin O.

unread,
Feb 13, 2014, 1:25:42 PM2/13/14
to robotframe...@googlegroups.com
Test WUKRT
    Wait Until Keyword Returns True    10s    2s    False Once    arg1    arg2

*** Keywords ***
Wait Until Keyword Returns True
    [Arguments]    ${timeout}    ${retry_interval}    ${name}    @{args}
    Wait Until Keyword Succeeds    ${timeout}    ${retry_interval}    Keyword Should Return True    ${name}    @{args}

Keyword Should Return True
    [Arguments]    ${name}    @{args}
    ${ret_val}=    Run Keyword    ${name}    @{args}
    Should Be Equal    ${ret_val}    ${True}

False Once
    [Arguments]    @{args}
    Log    ${args}
    ${called_already}=    Get Variable Value    ${FALSE_ONCE}    ${False}
    Set Global Variable    ${FALSE_ONCE}    ${True}
    [Return]    ${called_already}

Nikolay Ivanets

unread,
Feb 13, 2014, 3:01:12 PM2/13/14
to korm...@gmail.com, robotframe...@googlegroups.com

Thank you!

    ~ Sent from Android device ~

13 февр. 2014 г. 20:25 пользователь "Kevin O." <korm...@gmail.com> написал:
--
You received this message because you are subscribed to a topic in the Google Groups "robotframework-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/robotframework-users/5SCSWWVNyc0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/groups/opt_out.

Michael Tingey

unread,
Nov 30, 2014, 1:01:24 PM11/30/14
to robotframe...@googlegroups.com

I feel like I'm learning a new scripting language and great examples like this really help.  Thanks Kevin!!

It's taking a little bit of time to change the thinking because I keep looking for things like If-Then-Else, Case statements, etc.  And also asking myself questions like, "should I just write this in Python and create a new Keyword or is there a better way using the standard Keyword Libraries?".
Reply all
Reply to author
Forward
0 new messages