TestComplete function to capture system clock of computer
Hello, can someone tell or show me how can I capture the system clock time/date and use it to compare the time/date to an object property checkpoint value , and report the result to a log, pass if it matched.
Also if it can check the format if is correct as well but this can be a seperate check.
I am using Keyword scripting and if I can add it to a script routine it will be nice. Thank you !!
Hi Ned
"capture the system clock time/date"
Use the
aqDateTime.Today
method to get the current date.To obtain both the current date and time, use the
Now
methodTo obtain only the current time, use the
Time
method.Doc link: https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqdatetime/today.html
"to compare the time/date to an object"
The
aqDateTime.Compare
method compares two Date/Time values."I am using Keyword scripting and if I can add it to a script routine it will be nice."
Check my tutorial on this topic:
"How to check results"
Use -> aqDateTime.Compare
Result Value
An integer number that indicates the comparison result. The possible values are:
-1 Date1 is earlier than Date2 0 Date1 is equal to Date2 1 Date1 is later than Date2 Use these values inside if condition to obtain results.
let result = aqDateTime.Compare(Date1, Date2); if(result === 1) { Log.Checkpoint("It's 1!"); }
Hi nedbacan,
1) You can try to access this property from the first screenshot using the file object.innerText save it in the variable2) get the current time using the native TestComplete built in class. You have doc in my first entry
3) parse1 and 2 to the appropriate date format
4) use the native TestComplete solution to compare values.
I hope this will help you!