Forum Discussion

Feroz's avatar
Feroz
Occasional Contributor
7 years ago

How to generate a random number (Ex: 4 digit) and use it in my keyword tests,

Hi All,

I have a scenario where i need to use a random 4 digit number in my keyword tests. I tried below code snippet in my scripts but no luck. Could you please help me in this.

 

Code Used:

function randomWholeNum()

{

      var st1 = Math.floor(Math.random() * 20);
      return st1;
     //Log.Message(st1);
}

 

Expected:

random number..... but it is not returning any value

 

I want to return a value. So, that i can use 'Last Operation Result' method (In the Set variable method) and use it in my Keyword tests.

 

Thanks in Advance.

Regards,

Feroz

2 Replies

    • Feroz's avatar
      Feroz
      Occasional Contributor

      Thanks Shankar. My issue got fixed. 

      The issue was using the last operation Result, not with the code snippet.

      Anyways thanks for the reply :)

       

      Regards,

      Feroz