0

I have defined a list variable in the global variable section in Katalon studio, I want to retrieve the count of the list item and select any random value from it .

enter image description here

I have around 25 values,

enter image description here.

1 Answers1

1

Please try the below code:

def patientName = []
patientName = GlobalVariable.patientList
int length = patientName.size()
    
println "---->"+ length
    
int min = 0;
int max = length-1;
int random_int = (int)Math.floor(Math.random()*(max-min+1)+min);
    
def patientRetrieve = patientName[random_int]
println "---->"+ patientRetrieve
Jyoti Prakash Mallick
  • 2,119
  • 3
  • 21
  • 38