In tests provisioned from Dynatrace Recorder scripts, you may sometimes need to enter a random number in a text field or select a random option from a drop-down list, as opposed to using the static values recorded in the script.
var randNum = Math.round(Math.random() * MAXVAL);
MAXVAL with the maximum value your random integer can be. This line will set the
randNum variable to any integer between 0 and your
If you need a minimum value (denoted as
var randNum = Math.round(Math.random() * (MAXVAL - MINVAL)) + MINVAL;
The second method of creating a random number uses the current timestamp. This method is frequently used when a unique number is needed every time.
var hour = d.getHours();
var minute = d.getMinutes();
var month = d.getMonth();//This will return the month number between 0 (January) and 11 (December)
var year_4digit = d.getFullYear();
var year_2digit = d.getYear();
var seconds = d.getSeconds();
var day = d.getDay(); // This will return the weekday number between 0 (Sunday) and 6 (Saturday)