Monday, August 15, 2022

Capture the count of parameters in a file Neoload | Loop the parameter count times in Neoload | Neoload java script container

If you want to capture the count of parameters in a parameter file and loop the number of parameter times in  NeoLoad just use the java script code as below and get it done.

//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

//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.



Tuesday, August 9, 2022

Load runner to Neoload script converter with a command line tool | LR to Neoload Script Converter

A command-line utility called The Script Converter transforms LoadRunner scripts into NeoLoad projects.

Download the tool from here {Neotys Lab}:

Download Script Converter

Open Command Prompt and enter the following Command:

-source <LR Scripts folder> -target <NeoLoad output directory> -project <NeoLoad Project name

Example: 

Windows: .\script-converter.bat -source "C:\LoadRunnerScripts\TestHome" -target "C:\Users\Documents\NeoLoadProjects\TestHome" -project "TestHome"

Linux/OSX: ./script-converter.sh -source "/home/user/LoadRunnerScripts/TestHome" -target "/home/user/NeoLoadProjects/TestHome" -project "TestHome"

LR Scripts folder - Source directory where all scripts in each sub-directory will be converted into the output Project
NeoLoad output directory - The folder of the created NeoLoad Project
NeoLoad Project name - The name to assign to the NeoLoad project