Certification: AI-driven Test Automation

Dealing with Calendars and Dates

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:
  1. nowHour
  2. nowMinute
  3. nowMonth
  4. nowYear
  5. todayYear
  6. todayYearShort
  7. todayMonthNumber
  8. todayMonthNumberTwoDigits
  9. todayMonth
  10. todayMonthShort
  11. todayDayOfMonth
  12. todayDayOfMonthTwoDigits
  13. todayDayOfWeek
  14. 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

Test your knowledge

check that page contains expression “new Date().subtractDays(30).getYear()”
check that page contains expression “new Date().setDate(today.getDate()-30).getFullYear()”
check that page contains expression “new Date().getYear()-30.days()”
check that page contains expression “new Date().getFullDate()-30”

click “4 July”
select “4” from “July”
click “4” in the context of “July”
select “July” then click “4”