Forum Discussion
7 Replies
- Hassan_Ballan
Champion Level 1
Hello, I understand your application creates new record with ID string based on current date time (for example YYYYMMDDhhmmssSSS "20250108115133999") and you want to validate that it is the correct value.
Is that correct? can you provide your string format?If my assumptions is correct, you can do that with writing code to generate a string based on current date time, read the record ID value and compare it with the string you generated. The challenge would be the time difference from when the record was created and when you generate your string. To overcome I suggest you skip the seconds and milliseconds, and perhaps also skip the minutes.
The following documentation can help you https://support.smartbear.com/testcomplete/docs/scripting/working-with/index.html
- JDR2500Frequent Contributor
I agree with Hassan_Ballan,
First, the date/string format you get is a big factor. Without seeing the precise format, we can only speculate.
Second, checking for the exact time is a recipe for failure in my experience. As suggested, it would be more robust to skip at least everything after the minutes.
Third, a property checkpoint using a regular expression may be the way to go. That would give you greater flexibility over how you validate the value. See: Regular Expressions Syntax | TestComplete Documentation
Finally, there are aqDataTime methods that will let you extract the portions of the date/time you want and compare them. See: aqDateTime Object Methods | TestComplete Documentation
- RaghunandanitsOccasional Contributor
Hello Hassan_Ballan,
This is my date format, which i would like to validate - 02/01/2025 07:05 (dd/MM/YYY hh:mm) will check with the documentation. by the way I am using Keyword test.
- Hassan_Ballan
Champion Level 1
Hello Raghunandanits
The following example project should get you started and mimic some portions on how I set it up, it contains a keyword test that calls script to generate a sample log date as well as the required string that saves in the project variables LogString and StringDateTime. Also logs the values and does a comparison that fails.
Not being familiar with your project is hard to imagine how you are going to use it. But I think you have enough to implement your own design. Open the DateTime.mds file to view the project.
- rraghvani
Champion Level 3
Are you referring to the tested "value" that's changing which fails the checkpoint?
- RaghunandanitsOccasional Contributor
Yes, for example, once case is created each case will have unique case id which we would like to verify.
- rraghvani
Champion Level 3
Depending on your test scenario, you could implemented https://support.smartbear.com/testcomplete/docs/testing-with/data-driven/index.html
For example, if you are testing a calculator app, the result will always change depending on the input you have provided - use data driven testing for this.