Reputation: 228
Acc.to the Get Time Keyword in BuiltIn Library in Robot
${time} = Get Time time=NOW + 1h 2min 3s # 1h 2min 3s added to the local time
${time} is not in YYYY-MM-DD hh:mm:ss format but it has the following value
${time} = 27
Could you explain why?
Upvotes: 0
Views: 800
Reputation: 385910
If you look very closely at the documentation, the "time" parameter is actually named time_
rather than time
(note the trailing underscore). Since you aren't using the trailing underscore, robot is interpreting `time=NOW + 1h 2m 3s" as the format.
Because the format string (what it thinks is the format string) contains the string "min" it thinks you want the minute returned. Since it is treating this argument as the format string, the requested time defaults to the current time. If you wait one minute and run your test again, the result will change by one.
If you use the correct parameter name of time_
, your code will work as you intend. For example:
${time} = Get Time time_=NOW + 1h 2min 3s # 1h 2min 3s added to the local time
Upvotes: 2
Reputation: 6961
In the Robot Framework documentation for the keyword Get Time there are two arguments mentioned:
format=timestamp, time_=NOW
As you can tell your example is missing the _
*** Test Cases ***
Test Time
${time} = Get Time time_=NOW + 1h 2min 3s # 1h 2min 3s added to the local time
log to console ${time}
resulting in:
INFO : ${time} = 2020-01-18 17:24:16
Upvotes: 2