Last active
October 20, 2022 18:23
-
-
Save apallier/c3a6bde3b2be7cd28359281cf11085e4 to your computer and use it in GitHub Desktop.
Robot Framework: date management with DateTime library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** Settings *** | |
Library DateTime | |
Library Browser | |
*** Test Cases *** | |
Examples With Date | |
[Documentation] Examples of date format | |
${date}= Convert Date 1985-08-05 09:01:30 | |
${date}= Convert Date 19850805 090130 | |
${date}= Convert Date 1985-08-05 09:01:30.000 | |
# In the past | |
${date}= Convert Date 0001-01-01 # oldest date. The BC dates are not supported | |
${date}= Convert Date 1789-07-14 | |
# In the future | |
${date}= Convert Date 2200-01-01 | |
# With a formatting | |
${date}= Convert Date 05/08/1985 à 9:01 date_format=%d/%m/%Y à %H:%M | |
Create An Event In Calendar | |
[Documentation] Example of "realistic" testcase using date | |
${event_id}= Create An Event In Database At the doctor 2022-10-09 15:00 duration=30 min | |
# Retrieve event info from GUI | |
Browser.Go To www.example.com/calendar/${event_id} | |
${date_start_text}= Browser.Get Text id=startDate # = 09/10/2022 at 15:00 | |
${date_end_text}= Browser.Get Text id=endDate # = 09/10/2022 at 15:30 | |
${date_start}= Convert Date ${date_start_text} date_format=%d/%m/%Y at %H:%M | |
${date_end}= Convert Date ${date_end_text} date_format=%d/%m/%Y at %H:%M | |
# Checking | |
Should Be Equal ${date_start} 2022-10-09 15:00.000 | |
Should Be Equal ${date_end} 2022-10-09 15:30.000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment