//Declare a variable in a file.Adjust the path to your file variable as necessary.
var fileName = "C:\\Users\\NeoloadScripts\\Desktop\\Userid.txt";
Note: you can use any file here either txt or csv or any other text formats
var fileName = "C:\\Users\\NeoloadScripts\\Desktop\\Userid.txt";
Note: you can use any file here either txt or csv or any other text formats
//Read the File and get line count
var reader = new Packages.java.io.LineNumberReader(new Packages.java.io.FileReader(fileName));
while ((reader.readLine()) != null) {}
var lineCount = reader.getLineNumber();
reader.close();
If a file variable has a column header line, alter the value by deducting 1 from the value; otherwise, don't use.
var lineCount = lineCount-1
//Log value of line count from file
logger.debug("Line number is = "+lineCount);
//Return to the Neoload script a variable with the value of the line count.
context.variableManager.setValue("LoopCount",lineCount);
After this java script go to the go to the loop and in the settings-execute loop enter ${LoopCount} as shown in below.
No comments:
Post a Comment