Test synchronization

Relevant for: GUI tests and scripted GUI components

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 waits until your application is ready before performing a certain step.

There are several options that you can use to synchronize your test.

Add a synchronization point

If you do not want UFT to perform a step or checkpoint until an object in your application achieves a certain status, insert a synchronization point to instruct UFT to pause the test.

For example, suppose you record a test on a flight reservation application. You insert an order, and then you want to modify the order. When you click the Insert Order button, a progress bar is displayed and all other buttons are disabled until the progress bar reaches 100%. Once the progress bar reaches 100%, you record a click on the Update Order button.

Without a synchronization point, UFT may try to click the Update Order button too soon during a test run (if the progress bar takes longer than the test's object synchronization timeout), and the test will fail.

UFT must be able to identify the specified object to perform a synchronization point. To instruct UFT to wait for an object to open or appear, use an Exist or Wait statement.

Example: After you insert a synchronization point for the Flight Confirmation button, it may look something like this:

In the Editor, this is displayed as:

Browser("Welcome: Mercury Tours").Page("Flight Confirmation: Mercury").Sync
Browser("Welcome: Mercury Tours").Page("Flight Confirmation: Mercury").WebElement("Flight Confirmation#").WaitProperty "visible",true, 10000

Back to top

Exist and Wait Statements

Use Exist and/or Wait statements to instruct UFT to wait for a window to open or an object to appear. You can combine these statements within a loop to instruct UFT to wait until the object exists before continuing with the test.

For example, the following statements instruct UFT 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.

Back to top

Timeout Settings

If you find that, in general, the amount of time UFT 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 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 waits for a Web page to load, change the Browser Navigation Timeout in the File > Settings > Web pane.

Back to top