Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support times and x suffixes with WHILE limit to make it more compatible with Wait Until Keyword Succeeds #4975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vnkarthik87 opened this issue Dec 14, 2023 · 2 comments

Comments

@vnkarthik87
Copy link

Current Behaviour:
Currently, WHILE loop have argument 'limit' which handles both 'timeout' and 'number of times loop to iterate'.
In most of the Robotframework keywords, timeout functionality supports values without suffix (for example, argument value 300 is equivalent to 300 seconds)

When developers use the limit argument for timeout, they forget the suffix (s, sec, min...), as most of the keywords in RobotFramework supports timeout in seconds without suffix.

For example, below keywords in Robot Framework supports without suffix, except WHILE loop

Sleep   300    # Sleeps for 300 seconds
Wait Until Keyword Succeeds    300    30    My Keyword    args    # Retries My Keyword for 300 second, every 30 seconds
WHILE    ${status}==${TRUE}    limit=300    # Loops 300 times. This is conflicting with rest other keyword timeout argument values.

Feature Request (Either of Possibility 1 OR Possibility 2):

Possibility 1:
Can there be a timeout argument in addition to limit argument to support timeout even without suffix. (supports timestring, number or integer)
This will avoid additional instructions to RobotFramework Developers, that to be careful when providing 'limit' argument to WHILE loop. Below is the feature request example.

Example:

WHILE    ${status}==${TRUE}    limit=5    # Loops 5 times
WHILE    ${status}==${TRUE}    timeout=300    # Loops only for 5 minutes or 300 seconds

OR

Possibility 2:
Can there be a suffix added to limit, something like 'x' or 'times' as in 'Wait Until Keyword Succeeds'. Same argument name 'limit' should work for both timeout and number of times. 'timeout' argument name not required in this case.

Example:

WHILE    ${status}==${TRUE}    limit=5x    # Loops 5 times
WHILE    ${status}==${TRUE}    limit=10 times    # Loops 10 times
WHILE    ${status}==${TRUE}    limit=300    # Timeout after 5 minutes or 300 seconds of looping
WHILE    ${status}==${TRUE}    limit=2m    # Timeout after 2 minutes of looping
@pekkaklarck
Copy link
Member

Inconsistency like this isn't good. Comments to your proposals below:

  1. I'm afraid adding a separate timeout option would just add more confusing, especially if we would still support giving timeout also with limit (and not doing that would be badly backwards incompatible). Adding a new option would also require parser changes and thus be somewhat big task
  2. Supporting optional times and/or x prefixes with the current limit would be possible. It would also be easy to implement and fully backwards compatible.
  3. I doubt changing the meaning of limit=10 from ten times to ten seconds would be goo idea. At least for me it feels more logical in this context to interpret limit=10 as a count than as a times. Even if we agreed the other interpretation would be better, changing the behavior would be backwards incompatible. We couldn't just change it but instead needed to deprecate the old behavior first. That would be lot of work and most likely not worth the effort. Even if we'd consider the change worth the effort, it would be better to first introduce support for limit=10 times and only later deprecate the old meaning of limit=10.

I'll add times and x suffixes to limit to make WHILE more consistent with Wait Until Keyword Succeeds. After that both support formats like 10 s and 10 x the same way. Using just a number like 10 will continue to work differently but, as explained above, changing that would be backwards incompatible and not possible at least in RF 7.0.

@pekkaklarck pekkaklarck self-assigned this Dec 14, 2023
@pekkaklarck pekkaklarck added this to the v7.0 milestone Dec 14, 2023
@pekkaklarck pekkaklarck changed the title Feature Request: LIMIT timeout Argument in WHILE loop is not uniform across other Robot Framework keywords Support times and x suffixes with WHILE limit to make it more compatible with Wait Until Keyword Succeeds Dec 14, 2023
@pekkaklarck
Copy link
Member

If you nowadays use times=10 x, that is interpreted to mean 10 milliseconds. This is due to a bug in our timestr_to_secs utility function. I'll fix that as part of this issue as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants