Test synchronization
Relevant for: GUI tests and scripted GUI components
This topic explains how you can synchronize your tests, making sure steps are performed only when your application is ready for them.
When to consider synchronization
When you run a test, your application may not always respond with the same speed. For example, it might take a few seconds:
-
for a progress bar to reach 100%
-
for a status message to appear
-
for a button to become enabled
-
for a window or pop-up message to open
Handle these anticipated timing problems by synchronizing your test to ensure that UFT One waits until your application is ready before performing a certain step.
The sections below explain the different options available in UFT One for test synchronization.
Add a synchronization point
If you do not want UFT One to perform a step or checkpoint until an object in your application achieves a certain status, insert a synchronization point to instruct UFT One to pause the test.
For example, suppose you record a test on the Advantage Online Shopping website. You want to send feedback to the seller. You enter your email address, and then enter your suggestion or feedback in the Subject edit box. When you fill in the Email edit box and the Subject edit box, the Send button becomes available. However, you may want to modify your email address or feedback later.
Without a synchronization point, UFT One may try to click the Send button even before the button appears again in a test run, and the test will fail.
UFT One must be able to identify the specified object to perform a synchronization point. To instruct UFT One to wait for an object to appear, use an Exist or Wait statement.
Example: After you insert a synchronization point for the Send button, it may look something like this:
In the Editor, this is displayed as:
Browser("Advantage Shopping").Page("Advantage Shopping").WebEdit("emailContactUs").Set "123@google.com"
Browser("Advantage Shopping").Page("Advantage Shopping").WebEdit("subjectTextareaContactUs").Set "the laptop is good"
Browser("Advantage Shopping").Page("Advantage Shopping").Sync
Browser("Advantage Shopping").Page("Advantage Shopping").WebButton("send_btnundefined").WaitProperty "visible", true, 10000
Exist and Wait Statements
Use Exist and/or Wait statements to instruct UFT One to wait for a window to open or an object to appear. You can combine these statements within a loop to instruct UFT One to wait until the object exists before continuing with the test.
For example, the following statements instruct UFT One to wait up to 20 seconds for the Flights Table dialog box to open.
blnDone=Window("Flight Reservation").Dialog("Flights Table").Exist
counter=1
While Not blnDone
Wait (2)
blnDone=Window("Flight Reservation").Dialog("Flights Table").Exist
counter=counter+1
If counter=10 then
blnDone=True
End if
Wend
For details, see Add Synchronization Point Dialog Box.
Timeout Settings
If you find that, in general, the amount of time UFT One waits for objects to appear or for a browser to navigate to a specified page is insufficient, increase the default object synchronization timeout values for your test and the browser navigation timeout values for your test.
-
When working with tests, to modify the maximum amount of time that UFT One waits for an object to appear, change the Object Synchronization Timeout in the File > Settings > Run pane.
-
To modify the amount of time that UFT One waits for a Web page to load, change the Browser Navigation Timeout in the File > Settings > Web pane.