Can any body suggest me a function which I can use in QTP for following scenario...
As sometimes page navigation take times due to which our script shows an error. For that we use the wait(time)
function, but it is a fixed time for which the QTP control waits. I want to use a function (I have heard about the sync function, but don't know how to use it) so that QTP waits only for the time, time taken in navigation (not more/less then it).
The standard way of dealing with this kind of scenarios is to use .Sync method of the Page (or in some cases Browser) objects.
I found it very temperamental and depending on the tested application this function might work perfectly and on the other occasion will not wait long enough.
The problem seems to be related mainly to Web 2.0 applications (AJAX based). Web page connection to the server is usually closed much earlier then asynchronous connection opened by java script.
If there is a visual guide indicating that that page is still loading you could write a loop and check for that object. Once the object disappear you could resume test execution.
To save yourself writing this code in every place where you need to sync you could overwrite QTP native method with your own version with following code:
RegisterUserFunc "Page", "Sync", "SyncToPage"
Function SyncToPage(oPage)
'Call native function first'
oPage.Sync
'Custom sync code'
End Function
Thanks, Maciej
The sync functionality is what you want. You can use it in a variety of ways, such as:
Think about what is happening in the GUI to indicate to you that the operation has completed. This particular object and/or property is what you want to sync on.
http://qtp.blogspot.com/2007/09/qtp-sync-wait-and-synchronization.html
Other options include using the WaitProperty
and Exist
commands to synchronize the script with the application.
http://www.sqaforums.com/showflat.php?Number=555273
The QTP function reference should help with using these functions and explaining the parameters used. If you are still having issues, post a code segment so we can take a look.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With