Ask a Question

compare two variables between values

Occasional Contributor

compare two variables between values



I have textbox that show time with seconds.

I need to verify number of seconds pass from last reading, since the test take also time I have mistaken of +/-1 second in the test and that's OK.

How can I run test that will take account the accuracy of the test with +/-1 second?


I used one variable to store the previous time, and I variable that store the new time. how can I add checkpoint for time difference with +/- 1 second?

meaning, only if time difference is more or equal to 2 second, error should be record.





Valued Contributor

depending on your language 

you can use something like... (this is sudo code)

first if values are in string format convert to time..


now_time = String_todatetime("String_now_Time");
old_time = String_toDatetime("String_old_Time")

if your languge is VBScript may look like this

then compare .............

if ((now_time - old_time)=>2) {     Log.Error("got more than 2 secs"); }


Occasional Contributor

Hi NisHera,

Thank you for your response.

What is the difference between Log.Error and checkpoint compare?
When the test pass I can't see the green mark like in checkpoint.
There is only Log.Message no Log.Success option.
I'm new to TestComplete and I would be glad if you could elaborate on that.
Esteemed Contributor

If you would prefer, you could change the if-then logic code to this:

if ((now_time - old_time)=>2) {

    Log.Error("got more than 2 secs");

else Log.Checkpoint("Got 2 seconds"):

However, I would recommend what @NisHera wrote... why write to the log file information you don't need?  If you don't see an error, it passed.  The more you write to the log, the bigger the log size gets, and the more data you need to sort through to find whether or not something passed or failed.  So, @NisHera says, simply "If it failed, log it... if not... do nothing and assume it passeD".

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Occasional Contributor

Got it!


thank you both

Showing results for 
Search instead for 
Did you mean: