wait and synchronization in qtp
Asked Answered
D

1

5

What is the Difference between wait and synchronization function in QTP. And also please give an idea about what situation wait function can be used , and the situation synchronization function can be used.

Please help me out.

Dragonnade answered 10/12, 2012 at 10:2 Comment(0)
V
7

Browser.Sync or Page.Sync waits for the navigation to complete, which means that the page has been downloaded completely and successfully. This does not necessarily mean that all of the elements of the page have been downloaded (i.e., images, CSS, JS).

Wait is a hard-coded delay (wait X number of seconds). Wait should be avoided as much as possible. The script will run faster and more reliably if you use the built in synchronization functions of QTP (WaitProperty or Sync).

Taken directly form the QTP help text, below is a code example which displays an ideal time to use a Browser or Page level Sync.

SystemUtil.Run "iexplore.exe", "http://www.google.com"
Browser("Google").Page("Google").Sync
Browser("Google").Navigate "http://www.cnn.com"
Browser("Google").Page("CNN.com - Breaking News,").Sync
Wait 10 ' we can read the latest news
Browser("Google").Back
Vigil answered 10/12, 2012 at 16:9 Comment(4)
Hey Brian, what is the difference between Browser.sync and page.syncDryclean
@Dryclean - under most circumstances, the result of either method will be the same. Browser.Sync ties to the browser status bar indicating loading is complete. Page.sync waits for the page to load, ignoring frames and potentially other objects.Vigil
@Vigil - Could you please give an example of wait property or point us to a good source for examples ? Thanks.Presa
@Vigil - I have seen some code like browObj = Browser(abc).Page(mno). This is followed by .WebElement(xyz).Click.Sync. Does this mean sync on page or element ?Presa

© 2022 - 2024 — McMap. All rights reserved.