Sven van den Boogaart
Sven van den Boogaart

Reputation: 12325

Robotframework run for x amount of minutes

Im trying to run a test that is repeated for x amount of minutes. My idea for the keyword:

*** Keywords ***

Run test looped
   FOR    ${i}    IN RANGE    9999
      Do something
      Exit For Loop If    ${ELAPSED} > ${MAX_DURATION}
   END

Im trying to find how to calculate the elapsed time in minutes. I found the datetime type for robotframework but dont know how to get minutes elapsed. How can I get the elapsed time in minutes?

Upvotes: 0

Views: 530

Answers (2)

soyacz
soyacz

Reputation: 457

In builtin library there's Repeat Keyword - it does exactly what you need:

Repeat Keyword  2 minutes   Do Something    arg1    arg2

For more info see: http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Repeat%20Keyword

Upvotes: 2

Todor Minakov
Todor Minakov

Reputation: 20077

It's easier to work with epoch for such use cases - get it before the loop, and compare the current value inside it:

Run test looped
   ${start}=    Evaluate    time.time()    time
   FOR    ${i}    IN RANGE    9999
      Do something
      ${now}=    Evaluate    time.time()    time
      Exit For Loop If    (${now} - ${start})/60 > ${MAX_DURATION}    # divide the runtime seconds by 60, as ${MAX_DURATION} is in minutes
   END

Upvotes: 1

Related Questions