6.5 Time format

Robot Framework has its own time format that is both flexible to use and easy to understand. It is used by several keywords (for example, BuiltIn keywords Sleep and Wait Until Keyword Succeeds), DateTime library, and timeouts.

6.5.1 Time as number

The time can always be given as a plain number, in which case it is interpreted to be seconds. Both integers and floating point numbers work, and it is possible to use either real numbers or strings containing numerical values.

6.5.2 Time as time string

Representing the time as a time string means using a format such as 2 minutes 42 seconds, which is normally easier to understand than just having the value as seconds. It is, for example, not so easy to understand how long a time 4200 is in seconds, but 1 hour 10 minutes is clear immediately.

The basic idea of this format is having first a number and then a text specifying what time that number represents. Numbers can be either integers or floating point numbers, the whole format is case and space insensitive, and it is possible to add - prefix to specify negative times. The available time specifiers are:

  • days, day, d
  • hours, hour, h
  • minutes, minute, mins, min, m
  • seconds, second, secs, sec, s
  • milliseconds, millisecond, millis, ms

Examples:

1 min 30 secs

1.5 minutes

90 s

1 day 2 hours 3 minutes 4 seconds 5 milliseconds

1d 2h 3m 4s 5ms

  • 10 seconds

6.5.3 Time as "timer" string

Starting from Robot Framework 2.8.5, time can also be given in timer like format hh:mm:ss.mil. In this format both hour and millisecond parts are optional, leading and trailing zeros can be left out when they are not meaningful, and negative times can be represented by adding the - prefix. For example, following timer and time string values are identical:

Timer and time string examples
Timer Time string
00:00:01 1 second
01:02:03 1 hour 2 minutes 3 seconds
1:00:00 1 hour
100:00:00 100 hours
00:02 2 seconds
42:00 42 minutes
00:01:02.003 1 minute 2 seconds 3 milliseconds
00:01.5 1.5 seconds
-01:02.345 - 1 minute 2 seconds 345 milliseconds

results matching ""

    No results matching ""