RobotFramework - get current Date

robot framework elapsed time
subtract date from date robot framework example
how to select date from datepicker in robot framework
robot framework format date string
and in robot framework
how to install datetime library in robot framework
robot framework timestamp output
get library instance robot framework

I need to test that the current date is displayed on my device, The date on the device is in format Monday, September 9, 2018 but when i try to test it i can only use the format Monday, 09, 2018 which would fail the test as there is no 0 in the Month date.

    page should contain element  ${DATE}
    ${DATE_MESSAGE}  get current date  result_format=%A, %d, %Y
    element should contain text  ${DATE}  ${DATE_MESSAGE}

How can change the format in robotframework to verify THis format Monday, September 9, 2018.

ERROR should have contained text 'Monday, 09, 2018' but its text was 'Monday, September 9, 2018'.

Something like that should work:

${now}    Evaluate    '{dt.day}/{dt.month}/{dt.year}'.format(dt=datetime.datetime.now())    modules=datetime

After update:

${now}    Evaluate  '{dt:%A}, {dt:%B} {dt.day}, {dt.year}'.format(dt=datetime.datetime.now())    modules=datetime

RobotFramework - get current Date, To use Get Current Date you need to import DateTime library first. Please remember that DateTime is a new library so in case you have old version of Robot Framework, you need to either install library or upgrade RF. robot. """A test library for handling date and time values. ``DateTime`` is a Robot Framework standard library that supports creating and converting date and time values (e.g. `Get Current Date`, `Convert Time`), as well as doing simple calculations with them (e.g. `Subtract Time From Date`, `Add Time To Time`).

This can be done much more easy

${date}=      Get Current Date      UTC      exclude_millis=yes ${convert}=      Convert Date      ${date}      result_format=%a %B %d %H:%M:%S UTC %Y Log      ${convert}      console=yes

(%a = f.e. Mon %A = f.e. Monday %B = f.e. May %H:%M:%S - f.e. 13:04:09 UTC = f.e. part of string needed %Y = 2019)

The output on the console of the string above will give:

Fri May 10 10:12:31 UTC 2019

If you want to add certain amount of days use:

${date}=      Get Current Date      UTC      exclude_millis=yes ${plus14}=      Add Time To Date      ${date}      14 days ${future}      Convert Date      ${plus14}      result_format=%a %B %d %H:%M:%S UTC %Y Log      ${future}      console=yes

The output will be:

Fri May 24 10:12:31 UTC 2019

Robotframework: Getting date at runtime using Get Current Date, in , How do I get the current date in Robot Framework? Robotframework – Working with Date and Time December 25, 2017 Automation Testing , Robotframework , Selenium Comments: 3 Robot framework provides keywords for lot of stuffs.

Robot Framework has an extensive DateTime library built-in (since version 2.8.5).

If you are able to import that library, documented here ( http://robotframework.org/robotframework/latest/libraries/DateTime.html ). You should be able to use the Get Current Date keyword.

This keyword has a parameter that allows you to use Python's date formation format to get the date/time format you need.

How to write a loop while in Robot Framework, , you need to either install library or upgrade RF. get the current date and paste it the Publish on date field. get the current time and add 2 minutes with it and paste it to the time field. Then there was some additional test cases, like, save the content and check if the content properly published on the scheduled time. After that I needed to do the same 2 steps for the Un-publish on fields.

date time-get current date, get wrong format · Issue #2195 , How do I import a datetime library into robot framework? Hi, Not sure if I have something wrong about get current date, i just want to get the date like 2015-11-09 12:52. so I define date1 as "${date1} = Get Current Date increment=00:02:00, date_for

robotframework/get_current_date.robot at master · robotframework , How do I convert UTC datetime to local datetime in Python? Inputs and outputs identicla to 'Add to Date'. We probably will also implement 'Get Current Date'. It would work similarly as current 'BuiltIn.Get Time', but would support same date formats as 'Convert Date'. Alternatively we may enhance 'Get Time' (likely hard due to backwards-compatibility requirements) or just decide this isn't needed.

robot.libraries.DateTime, How do you write a for loop in Robot Framework? Epoch time. Epoch time is the time in seconds since the UNIX epoch i.e. 00:00:00.000 (UTC) 1 January 1970. To give a date in epoch time, it must be given as a number (integer or float), not as a string. To return a date in epoch time, it is possible to use epoch value with result_format argument.

Comments
  • Which format you want ? your question seem so blur
  • @SidaraKEO i have update the question sorry for the misuderstaing
  • Sorry I have missphrased my question i have added the fail message and updated the question
  • 'Monday, 9, 2018' but its text was 'Monday, September 10, 2018'. i am getting this error
  • See how to format code properly, you don't have to put all those