Generative AI-Based Testing Certification
Dealing with Dates and Times
Because of the ever-changing nature dates and time, test cases that depend on them always need to have the flexibility of parameterization. This flexibility starts with the ability to dynamically change the current date and time.
- todayYear – (2023)
enter stored value "todayYear" into "YYYY"
example - todayYearShort – (23)
enter stored value "todayYearShort" into "Year"
example - todayMonthNumber – (9)
enter stored value "todayMonthNumber" into "Month"
example - todayMonthNumberTwoDigits – (09)
enter stored value "todayMonthNumberTwoDigits" into "Month"
example - todayMonth – (September)
click stored value "todayMonth"
example - todayMonthShort – (Sep)
click stored value "todayMonthShort"
example - todayDayOfMonth – (2)
enter stored value "todayDayOfMonth" into "Month"
example - todayDayOfMonthTwoDigits – (02)
enter stored value "todayDayOfMonthTwoDigits" into "Month"
example - todayDayOfWeek – (Monday)
enter stored value "todayDayOfWeek" into "Day"
example - todayDayOfWeekShort – (Mon)
enter stored value "todayDayOfWeekShort" into "Day"
example - nowHour – (2 or 14)
select stored value "nowHour" from "Start time"
example - nowHourTwoDigits – (02 or 14)
select stored value "nowHourTwoDigits" from "Start time"
example - nowHourAmPm – (2)
select stored value "nowHourAmPm" from "Itinerary"
example - nowHourTwoDigitsAmPm – (02)
select stored value "nowHourTwoDigitsAmPm" from "Itinerary"
example - nowAmPm – (PM)
select stored value "nowAmPm" from "Time of day"
example - nowMinute – (5)
enter stored value "nowMinute" into "Start time"
example - nowMinuteTwoDigits – (05)
enter stored value "nowMinuteTwoDigits" into "Start time"
example - nowSecond – (7)
enter stored value "nowSecond" into "Sec"
example - nowSecondTwoDigits – (07)
enter stored value "nowSecondTwoDigits" into "Sec"
example - nowNanosecond – (355881000)
save string with parameters "email${nowNanosecond}@testrigor-mail.com" as "newEmail"
example - nowDateIso – (2023-09-02)
save stored value "nowDateIso" as "currentDate"
example - nowTimeIso – (02:05:07)
save stored value "nowTimeIso" into "currentTime"
example - nowDateTimeIso – (2023-09-02T02:05:07.165068-07:00[America/Los_Angeles])
save stored value "nowDateTimeIso" as "currentDateTime"
example - nowMillisecondsFrom1970 – (1637061365335)
save stored value "nowMillisecondsFrom1970" as "timeStamp"
example - nowDateTimeRFC1123UTC – (Mon, 16 Sep 2023 16:32:41 GMT)
save stored value "nowDateTimeRFC1123UTC" as "currentDateTime"
example - nowUnixTime – (1637061404)
save stored value "nowUnixTime" as "currentUnixTime"
example
Note: Time is always generated based on the time zone indicated in the suite settings. In Settings
->Advanced
, select the desired location from the time zone dropdown.
save string with parameters "${todayMonth} ${todayDayOfMonth}, ${todayYear}" as "todayFullDate"
The above command will produce a the variable todayFullDate
with a value that would look like August 15, 2024
.
Calendars and Pickers
click
and/or select
:click "next month" until "calendar" contains stored value "todayMonth"
click stored value "todayDayOfMonthTwoDigits" in the context of stored value "todayMonth"
enter
command is usually best:enter stored value "todayMonth" into "month"
enter stored value "todayDayOfMonth" into "day"
enter stored value "todayYear" into "year"
Getting past and future dates dynamically
Day of the month
Save the date one day from the current date (a single digit [1
] if the date is less than the “10”)
save expression "var d = new Date();d.setDate(d.getDate()+1);''+d.getDate();" as "tomorrow"
+1
in d.setDate(d.getDate()+1)
to set the date in the expression to a date a certain number of days before or after the current date. Use +
for days in the future and -
for days in the past.01
] if the date is less than the “10”)check that page contains expression "var d = new Date();d.setDate(d.getDate()+2);('0' + d.getDate()).slice(-2);"
Month of the year
1
] if the month is January to September)save expression "var d = new Date();d.setDate(d.getDate()+30);''+(d.getMonth()+1)" as "nextMonth"
01
] if the month is January to September)save expression "var d = new Date();d.setDate(d.getDate()+60);('0' + (d.getMonth()+1)).slice(-2)" as "monthAfterNext"
Jan
) will be in 30 days into a variable.save value from expression "var ms = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];var tda = new Date();tda.setDate(tda.getDate()+30); ms[tda.getMonth()];" as "shortMonth30Days"
January
) will be in 60 days into a variable.save value from expression "var ms = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];var tda = new Date();tda.setDate(tda.getDate()+60); ms[tda.getMonth()];" as "fullMonth60Days"
Year
2025
) year will be in 365 days from the current day.save expression "var aDate=new Date();aDate.setDate(aDate.getDate()+365);''+aDate.getFullYear()" as "nextYear"
25
) year was 365 days ago from the current day.save expression "var d = new Date();d.setDate(d.getDate()-365);year = d.getFullYear(); ''+d.getFullYear();year.toString().substr(-2);" as "twoDigitYear"
Full date
1/21/2024
).save value from expression "var d = new Date();d.setDate(d.getDate()+1);d.getMonth()+ 1+'/'+d.getDate()+'/'+d.getFullYear()" as "tomorrowMonthDayYear"
21/1/2024
).save value from expression "var d = new Date();d.setDate(d.getDate()-1);d.getDate()+ 1+'/'+d.getMonth()+'/'+d.getFullYear()" as "yesterdayDayMonthYear"
01/21/2024
).save value from expression "var d = new Date();d.setDate(d.getDate()+1);('0' + (d.getMonth()+1)).slice(-2)+'/'+('0' + d.getDate()).slice(-2)+'/'+d.getFullYear()" as "tomorrowMonthDayYearTwoDigits"
January 1, 2025
).save value from expression "var ms = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];var tda = new Date();tda.setDate(tda.getDate()+12); ms[tda.getMonth()] + ' ' + [tda.getDate()] +', ' + tda.getFullYear();" as "todayNextMonth"
January 01, 2025
).save value from expression "var ms = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];var tda = new Date();tda.setDate(tda.getDate()+30); ms[tda.getMonth()] + ' ' + ('0' + tda.getDate()).slice(-2) +', ' + tda.getFullYear();" as "todayNextMonthDoubleDigit"
Jan 01, 2025
).save value from expression "var ms = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];var tda = new Date();tda.setDate(tda.getDate()+7); ms[tda.getMonth()] + ' ' + ('0' + tda.getDate()).slice(-2) +', ' + tda.getFullYear();" as "nextWeekShortMonth"
January 1st, 2025
).save value from expression "var ms = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];var d=['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th', '11th', '12th', '13th', '14th', '15th', '16th', '17th', '18th', '19th', '20th', '21st', '22nd', '23rd', '24th', '25th', '26th', '27th', '28th', '29th', '30th', '31st'];var tda = new Date();tda.setDate(tda.getDate()+7); ms[tda.getMonth()] + ' ' + d[tda.getDate()] + ', ' + tda.getFullYear();" as "nextWeekOrdinal"