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

 

lets discuss it one by one.

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("mainpage").Page("form1")
obj.Link("select").Click
obj.Link("Select Country").WaitProperty "text", "Simple Interest",10000
obj.Link("Select Country").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("mainpage").Page("form1")
obj.Link("select").Click
If obj.Link("Select Country").Exist(30) Then
obj.Link("Select Country").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("mainpage").Page("form1")
obj.Link("select").Click
wait(30)
obj.Link("Select Country").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("mainpage").Page("form1")
obj.Link("select").Click
wait(30)
obj.Link("Select Country").Sync


Default Synchronization:

When user hasn’t used any of the above sync methods, still QTP has inbuild Object synchronization timeout which can be adjusted by the user.

Synchronization in UFT
Synchronization in UFT

Navigate to “File” >> “Settings” >> Run Tab >> Object Synchronization Time out as shown below.

 

More topics on UFT you can find in UFT section 

You might also like More from author

Loading...