Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Delay Time in QTP
#1
Solved: 11 Years, 4 Months, 1 Week ago
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
Reply
#2
Solved: 11 Years, 4 Months, 1 Week ago
Hi,
Below is the wait/sleep statement for QTP.

Wait <time in Seconds>
ex: Wait 2

Reply
#3
Solved: 11 Years, 4 Months, 1 Week ago
Use Like below:

WScript.Sleep 1000
Reply
#4
Solved: 11 Years, 4 Months, 1 Week ago
Hi,

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

Thanks & Regards,
Kamalakannan Anandan
Reply
#5
Solved: 11 Years, 4 Months, 1 Week ago
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)
Reply
#6
Solved: 11 Years, 4 Months, 1 Week ago
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
Reply
#7
Solved: 11 Years, 4 Months, 1 Week ago
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Time Delay issue with Exist mv8167 11 24,866 06-19-2017, 02:56 PM
Last Post: grosorg
  Delay between keystrokes Alobarb 0 2,674 01-13-2012, 11:48 PM
Last Post: Alobarb

Forum Jump:


Users browsing this thread: 2 Guest(s)