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.

Nikhil Surendran
  • 956
  • 4
  • 14
  • 25

1 Answers1

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
BrianJM
  • 301
  • 1
  • 7
  • Hey Brian, what is the difference between Browser.sync and page.sync – codeomnitrix Jul 26 '13 at 08:25
  • 2
    @codeomnitrix - 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. – BrianJM Jul 26 '13 at 20:45
  • @BrianJM - Could you please give an example of wait property or point us to a good source for examples ? Thanks. – MasterJoe Feb 13 '18 at 21:59
  • @BrianJM - 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 ? – MasterJoe Feb 13 '18 at 22:02