Micro Focus QTP (UFT) Forums
How do I randomize how long a wait state waits? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How do I randomize how long a wait state waits? (/Thread-How-do-I-randomize-how-long-a-wait-state-waits)



How do I randomize how long a wait state waits? - luck91 - 08-14-2008

Wait (X)

I want X to represent a random value within a parameter. For instance, I want to be able to set my random value to be in between 5 and 500 seconds so that the first time I loop through the Wait (X) that X might equal 121 and the next time it might equal 6 and so on with any valid Wait random value between 5 and 500. Can this be done? Syntax please :-)


RE: How do I randomize how long a wait state waits? - Ankur - 08-14-2008

While it can be done easily, I am not sure why you want a hard coded statement in your scripts... a sync statement or a loop which checks for the existence of an object would be better...
anyways here goes the syntax...

Code:
Dim X

X = Int(596 * rnd() + 5) ' This will generate an integer between 5 and 500

wait(X)