Micro Focus QTP (UFT) Forums
Delay Time in QTP - 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: Delay Time in QTP (/Thread-Delay-Time-in-QTP)



Delay Time in QTP - kamalakannan_anandan - 05-26-2011

Hi,

I am new QTP, How to set Delay Time in QTP vb Script

Here sample Code

Code:
Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("passCount").Select "4"
Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("fromPort").Select "New York"
'Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("fromMonth").Select "December"
WScript.Sleep( 1000 )
Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("fromMonth").Select "January"
WScript.Sleep(1000)
Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("fromMonth").Select "February"
WScript.Sleep(1000)

WScript.Sleep(1000) It Show a error message

Object Required: WScript

Please Help me to solve this problem.

Thanks & Regards,
Kamalakannan Anandan


RE: Delay Time in QTP - vIns - 05-26-2011

Hi,
Below is the wait/sleep statement for QTP.

Wait <time in Seconds>
ex: Wait 2




RE: Delay Time in QTP - Palanimurugana - 05-26-2011

Use Like below:

WScript.Sleep 1000


RE: Delay Time in QTP - kamalakannan_anandan - 05-26-2011

Hi,

Thanks for u r support, It's working correctly.

Thanks & Regards,
Kamalakannan Anandan


RE: Delay Time in QTP - Skepsis - 06-13-2011

A better way is to wait for the object, with a time out (say 10 seconds) this way you can handle failures too and variations between machines.

(this is psudo code while loop is probably better)

Code:
continue = false
for x = 1 to 10
  if (object exists) then
    continue = true
    x = 10
  endif
  wait(1000)
next
if continue <> true then (fail with approperate error)



RE: Delay Time in QTP - tbien - 07-04-2011

Code:
public Function waitForElement(element)

Dim n

for n=0 to 1000 step 1
    If element.Exist then
        n=1000
        Else wait 1
        End If
Next

End Function



RE: Delay Time in QTP - rajpes - 07-04-2011

Code:
Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("passCount").Select "4"
Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("fromPort").Select "New York"
wait 1
Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("fromMonth").Select "January"
wait 1
Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("fromMonth").Select "February"
wait 1