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 variables:
  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 generated based on the time zone indicated in the suite settings. In Settings -> Advanced, select the the desired location from the time zone dropdown.

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 "var aDate=new Date();aDate.setDate(aDate.getDate()-30);''+aDate.getFullYear()"
For selecting dates on a calendar, just use click and select:
click "4" in the context of "July"
click "next month" until page contains "August"
For selecting dates on a 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 "var aDate=new Date();aDate.setDate(aDate.getDate()-30);''+aDate.getFullYear()"

Various date format snippets

Use string with parameters command, for example:
string with parameters"${todayMonth} ${todayDayOfMonth}, ${todayYear}"

The above command will get a result like: August 15, 2024

Test your knowledge

check that page contains expression “new Date().subtractDays(30).getYear()”
check that page contains expression “var aDate=new Date();aDate.setDate(aDate.getDate()-30);”+aDate.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”
[wpcode id=”1112380″ answers=”2;3″ page=”Dealing with Calendars and Dates” numoffields=”2″]