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
This is how we can generate random numbers in QTP.
Please give your inputs, suggestions, feedback to Us. We value your thoughts.
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
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