Want to check couple of metadata from a variable file in javascript action to decide if update that file or not.
Hello Michel
I don't know if it possible to get file metadata from a javascript action on Neoload. Indeed, even browsers have to implement FileReader interface for a javascript code to access file on the client.
But you can use two files : the one you already have and a second one containing the metadata of your first file. And you just have to fetch those metadata thanks to a shell script action executed by Neoload at some point of your test.
So you will check in your second file variable the state of your first file.
Best Regards,
Fousseyni B.
Thanks Fousseyni, actually I find out that code below works for my purpose, the only thing that I am struggling now is how to get project path folder (variables folder)
var file = new java.io.File("{folder}\\variables\\datafile.txt");
logger.info(new Date(file.lastModified()));
Hello Michel,
You can copy your file containing your variable inside the "custom-resources" folder (Neoload installation folder) without any subfolders otherwise it won't work. And you will access it from ${NL-CustomResources} or using a javascript : context.variableManager.getValue("variable")
Best Regards,
Fousseyni B.
Hi again, one more question... but before that let me contextualize you what I am trying to do: I want to have a file variable that has as content a returned query from SQL, but I would like to validate if that data is old enough to re-run a query and update content. So, my strategy is having this variable file, check with javascript if it is old enough, if so I run again a SQL statement and write/update the same file.
Said that, my question is: NL-CustomResources will return a path inside AppData, solves one of my problems, but now I still need to have a way to identify the project folder path to write/update the original file (in variables or custom-resources folder inside my project) with new content.
In fact, if that SQL variable had a validation like, "is this file content older than 1 month? THEN run again the sql statement, ELSE, do not run sql query and keep using the same temp content file" it will do the same that I am trying to achieve