Information:

Environment

  • Dynatrace Portal
  • Dynatrace Recorder
Symptoms

Setting a script to select a random value from an array.

Solution

To configure a script to select a random value from an array:

  1. Create your list.
  2. Code a random function call to select one of those values.
  3. Assign the function call to the desired element.


For example:

var myList = new Array("Honda","Toyota","Ford");
var reqValue = myList[Math.floor(Math.random()*3)]
document.getElementById('myCar').value = reqValue


You can use the above code wherever you can use JavaScript in Dynatrace Recorder script.

 

 

 

 

  • No labels