Answered question

CurrentDate variable does not update at runtime

version 6.10.0
NeoLoad CurrentDate variable doesn't get updated during runtime.
I have tried Local and Global and each change policy but each run inserts the datetime when the variable was created.

william S.
william S.

william S.

Level
0
69 / 100
points

Did you find this useful ?

No (0)

Yes (1)

100%

100% of users found this answer useful

Other answers

william S.
william S.

william S.

Level
0
69 / 100
points

Hi Neil,
Thanks but nope. This is not a formatting issue, it's that the CurrentDate variable provided by NeoLoad doesn't update.
My workaround is to code it:
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var dateTime = date+' '+time;

this is working.

Could it be a defect with the app?

william S.
william S.

william S.

Level
0
69 / 100
points

here is my js:
var lock = new java.util.concurrent.locks.ReentrantLock();
var currDate = context.variableManager.getValue("CurrentDate");

var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var dateTime = date+' '+time;

lock.lock();
var writer = new java.io.FileWriter("c:/currDate.txt",true);
writer.write(currDate);
writer.write(" -- ")
writer.write("NeoLoad Variable")
writer.write("\r\n");
writer.write(dateTime);
writer.write(" -- ")
writer.write("\r\n");
writer.close();
lock.unlock();

i added a 1s delay and ran in 100 times in the UserPath checker comparing NeoLoad CurrentDate variable and my js variable. The results are in the file below. You will notice that my date variable changes but the NeoLoad canned variable does not. It shows the date that the variable was created.

william S.
william S.

william S.

Level
0
69 / 100
points

sure, go ahead

william S.
william S.

william S.

Level
0
69 / 100
points

thanks Neil,
i noticed that your currDate variable was different than mine. it appears that the variable was not correctly created. once corrected, the date does update.