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
1
115 / 750
points
Neil W.
Neil W.

Neil W.

Level
4
5000 / 5000
points
Team

Here is a working project from 6.10

Did you find this useful ?

No (0)

Yes (1)

100%

100% of users found this answer useful

Other answers

Neil W.
Neil W.

Neil W.

Level
4
5000 / 5000
points
Team
william S.
william S.

william S.

Level
1
115 / 750
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?

Neil W.
Neil W.

Neil W.

Level
4
5000 / 5000
points
Team

I will try with v6.10 tomorrow (well later today now) but v7 is out so maybe an upgrade is needed.

Nouredine A.
Nouredine A.

Nouredine A.

Level
4
5000 / 5000
points
Team

I can't reproduce that issue in NeoLoad 6.10. Could you provide more information about your use case like when/where and how often the variable is called?

william S.
william S.

william S.

Level
1
115 / 750
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.

Neil W.
Neil W.

Neil W.

Level
4
5000 / 5000
points
Team

We would need to see some screenshots of how you have created this, I can create a quick demo project and share it here.

william S.
william S.

william S.

Level
1
115 / 750
points

sure, go ahead

william S.
william S.

william S.

Level
1
115 / 750
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.