Search code examples
robotframeworkbuilt-in

${time} = Get Time time=NOW + 1h 2min 3s # 1h 2min 3s added to the local time


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?


Solution

  • 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