Certification: AI-driven Test Automation
Certification: AI-driven Test Automation
Dealing with Calendars and Dates
In some tests, you will need to specify the current date/time of when the test is being run.
testRigor supports the following pre-defined values:
- nowHour
- nowMinute
- nowMonth
- nowYear
- todayYear
- todayYearShort
- todayMonthNumber
- todayMonthNumberTwoDigits
- todayMonth
- todayMonthShort
- todayDayOfMonth
- todayDayOfMonthTwoDigits
- todayDayOfWeek
- todayDayOfWeekShort
Note: time is always in UTC in testRigor
If you need to calculate a date in the future or past – for example, check that a year from 30 days ago is present on the screen – use ECMAScript 5.1 compatible expressions.
check that page contains expression "new Date().setDate(today.getDate()-30).getFullYear()"
For selecting dates on a calendar/date picker, just use click and select:
click "4" in the context of "July"
click "next month" until page contains "August"
Getting dates dynamically
Using JavaScript, like this:
check that page contains expression "new Date().setDate(today.getDate()-30).getFullYear()"
Various date format snippets
Use string with parameters command, for example:
string with parameters"${todayDayOfMonth} ${todayMonth} ${todayYear}" - to get the result like: 15 August 2023