Ask a Question

Ability to generate random values at runtime and pass it in as a parameter

0 Kudos

Ability to generate random values at runtime and pass it in as a parameter

Should have an ability to generate random unique values at runtime or append a random value to a variable like "TestUser_<random number / timestamp>", for scenarios such  as username in signup functionality. 

1 Comment

Hi pranoti,


Thank you for submitting a feature request. In LoadNinja, it is possible to generate some values at runtime and append them, for example, to a string using JavaScript validations. We can, for example, use a JS validation to access an input field on a page, and fill it with a string generated at runtime. See sample JS validation code below:

function _InputValue() {

  var element = document.getElementById("testInputId");

  const months = ["JAN", "FEB", "MAR", 
                  "APR", "MAY", "JUN", 
                  "JUL", "AUG", "SEP", 
                  "OCT", "NOV", "DEC"];

  const code = "PRG";
  var dateNow = new Date();

  var year = dateNow.getFullYear();
  var month = months[dateNow.getMonth()];
  var day = dateNow.getDate();

  var hours = dateNow.getHours();
  var minutes = dateNow.getMinutes();
  var seconds = dateNow.getSeconds();
  var miliseconds = dateNow.getMilliseconds();

  var textFieldValue = code + year + month + day + 
      hours + minutes + seconds + miliseconds;

  if (element){

    element.value = "";
    element.value = textFieldValue;
    return true;
  return false;

return _InputValue();

This sample code is creating a unique string starting with "PRG" and contains a date generated at runtime. 


See also: Documentation - JavaScript validations for more information.


Best regards,


Customer Care Engineer

Welcome to the LoadNinja Feature Requests board!

Here you can review submitted feature requests and vote up the ones you like! If you can't find the feature you want - go ahead and suggest your own idea. Ideas with the highest rating can be implemented in the product.

Check out the Create a Feature Request guide for more information.
New Here?
Welcome to the Community
Sign Up Here