Synchronization in UFT
When we automate the
script most of the time we faced several issues with performance of
application. sometimes application becomes slow in response sometimes fast.
then how we show make sure that our script should run in irrespective of the
application performance and response?
all automation tools
provide specific functions which handles these performance issue. UFT also
has Synchronization mechanism to make sure that script will not fail.
Lets discuss more about
the Synchronization.
There are 5 different
ways to handle the synchronization.
- WaitProperty
- Exist
- Wait
- Sync(only for web based apps)
- Default Synchronization
WaitProperty:
WaitProperty
is a method which can be apply on any object in UFT. It takes the
property name, Value and Timeout value as input to perform the sync. It is a
dynamic wait, it means once the object is get visible/enable or state becomes
true corresponding action gets performed. so it is highly recommended options.
Example
: lets put wait for 10secs
Dim obj
Set obj =
Browser("XX").Page("XX")
obj.Link("select").Click
obj.Link("XX").WaitProperty
"text", "Simple Interest",10000
obj.Link("XX").Click
Exist: Exist
menthod ensure that object is present on the screen or not. Exist is a method
that takes the Timeout value as input to perform the sync. it is a
dynamic wait similar to Waitproperty and hence this option is also
recommended.
Dim obj
Set obj =
Browser("XX").Page("XX")
obj.Link("XX").Click
If obj.Link("XX").Exist(30)
Then
obj.Link("XX").Click
Else
Print "object
does not exists";
End If
Wait
Wait
Method puts hardstop on wait. if you use this method then thread of
execution will stop for defined set value.this wait method is not recommended
unless you don’t have another option.
Dim obj
Set obj =
Browser("XX").Page("XX")
obj.Link("XX").Click
wait 30
obj.Link("XX").Click
Sync Method
sometimes
pageload time varies. to wait for it Sync method can be used. Method can be
used only for web applications where there is always a lag between page loads.
Dim obj
Set obj =
Browser("XX").Page("XX")
obj.Link("XX").Click
wait 30
obj.Link("XX").Sync
Default Synchronization: When
user hasn’t used any of the above sync methods, still QTP has in build Object
synchronization timeout which can be adjusted by the user.
Synchronization in UFT
Navigate to “File” >> “Settings” >> Run Tab >> Object Synchronization Time out as shown below.
0amenKremi-Billings Amber Helmbrecht https://wakelet.com/wake/bGWNz6UUFX_Zg92CFMFhA
ReplyDeleteanfarale