Synchronization in UFT – User friendly Tech help

We are already done with the synchronization in selenium, today we would discussing the same in UFT.Before starting with the synchronization we would recommend to use Exist,WaitProperty,Sync rather than using Wait.

n

1.wait
nThis is used when we want UFT to wait for the specified time, so that AUT completes its current operations.It is like pausing the script run for the given amount time(Same like Thread.sleep)
nSyntax:- Wait (seconds)
nExample:- wait(2)
nGiven script will pause for 2 seconds.
nNote:- if we don’t pass any value  like wait()
nit Will generate runtime error.

n

n

n

n

n

n

n

n

Wait,generated Error for missing Time value

n

Using Wait is not considered as good coding practice, because it is like pausing the script independent of any condition and UFT would wait even if the process for which wait was applied have been completed.We can still use it if nothing from the below properties or methods works out , or we are sure that process will always takes a given amount of time.
n
n2.waitproperty
nIs it used to Wait until the the given object property achieves the specified value in the given timeout else it continues to the next step.
nSyntax:-object.WaitProperty(PropertyName, PropertyValue, [TimeOut])
nNote:- Timeout(milliseconds) is optional,incase it is not provided default synchronization timeout is taken(File->Settings->Run->Object synchronization timeout)
nReturn Type:- Boolean (True incase property value is achieved in the given Timeout)
nExample:-

n

'To wait for 30 seconds for the the Home link to be loaded 
Set obj = Browser("CreationTime:=0").Page("Index:=0").Link("text:=HOME","html tag:=A")
If obj.WaitProperty("attribute/readyState", "complete", 3000) Then obj.Click
EndIf

n

n3.exist Property
nIt instructs UFT to wait for a specified object to appear. 
nSyntax:-
nObject.Exist(Timeout)
nReturn Type:-Returns a boolean value indicating whether or not an object currently exists
nNote:- Timeout(seconds) is optional,incase it is not given it would take the default synchronization timeout (File->Settings->Run->Object synchronization timeout)
nExample:-

n

'Code to wait for 30 seconds for the Link to exist
Set obj = Browser("CreationTime:=0").Page("Index:=0").Link("text:=HOME","html tag:=A")
If obj.Exist(30) Then obj.Click
End If

n

n4.sync Method(Only for Web AUT)
nWaits for the browser to complete the current navigation.
nSyntax:-
nObject.Sync
nExample:-

n

'Waits for the Page to load
Browser("CreationTime:=0").Page("Index:=0").Sync

n

nHow to modify Default Timeout values:-
nNote:- Default ‘object’ sync time is 20 seconds and Browser ‘Navigation’ sync is 60 seconds
nSync:-
nFile > Settings > Web pane

n

n

n

n

n

n

n

n

Changing Browser Navigation Time 

n

Exist,WaitProperty:-
nFile->Settings->Run->Object synchronization timeout
nWe can always play with the default synchronization time that UFT takes for Exist,WaitProperty or by default before it throws error to the user.

n

n

n

n

n

n

n

n

Changing Object Sync in UFT

n

Learn UFT
nLearn Selenium

Was this article helpful?
YesNo

Similar Posts