Tuesday, 30 July 2013

How to generate the random number in QTP ?

QTP supports the function called Rnd that generates random value between 0 and 1.

rnd function takes 1 input parameter which acts as a seed to generated further random numbers in sequence.

To initialize the seed with system timer, you can use below statement.

Randomize


To generate the random integers we can use below statement.

Method 1
min = 1
max = 100

Randomize
RandomInt1= (Int((max-min+1)*Rnd+min))
RandomInt2= (Int((max-min+1)*Rnd+min))

print RandomInt1  'print the first random integer between 1 and 100.
print RandomInt2  ' print the second  random integer between 1 and 100.


Method 2

x=RandomNumber (0,100)
print x

This is how we can generate random numbers in QTP.


Please give your inputs, suggestions, feedback to Us. We value your thoughts.

No comments:

Post a Comment

Please Leave your reply. We value your feedback and inputs

Best QTP Books

Everything About QTP

Hello Friends,
You can find QTP study material, Multiple choice questions (mcq), QTP question bank, QTP question papers, QTP notes, QTP questionnaire, scenario based QTP interview questions, QTP tutorial and QTP training on this site.

If you are a fresher or experienced QTP professional with (1/2/3/4) years of experience, this blog is just for you.