Page Synchronization for xBrowser

Synchronization is performed automatically before and after every method call. A method call is not started and does not end until the synchronization criteria is met.

Note: Any property access is not synchronized.

Synchronization Modes

Silk Test Workbench includes synchronization modes for HTML and AJAX.

Using the HTML mode ensures that all HTML documents are in an interactive state. With this mode, you can test simple Web pages. If more complex scenarios with Java script are used, it might be necessary to manually script synchronization functions, such as:
  • WaitForObject
  • WaitForProperty
  • WaitForPropertyNotEquals
  • WaitForDisappearance
  • WaitForChildDisappearance
  • WaitForScreenshotStable

The AJAX mode synchronization waits for the browser to be in a kind of idle state, which is especially useful for AJAX applications or pages that contain AJAX components. Using the AJAX mode eliminates the need to manually script synchronization functions (such as wait for objects to appear or disappear, wait for a specific property value, and so on), which eases the script creation process dramatically. This automatic synchronization is also the base for a successful record and playback approach without manual script adoptions.

Troubleshooting

Because of the true asynchronous nature of AJAX, generally there is no real idle state of the browser. Therefore, in rare situations, Silk Test Workbench will not recognize an end of the invoked method call and throws a timeout error after the specified timeout period. In these situations, it is necessary to set the synchronization mode to HTML at least for the problematic call.

Note: Regardless of the page synchronization method that you use, in tests where a Flash object retrieves data from a server and then performs calculations to render the data, you must manually add a synchronization method to your test. Otherwise, Silk Test Workbench does not wait for the Flash object to complete its calculations. For example, in a visual test, use Delay and in a script, use System.Threading.Thread.Sleep(millisecs).

Some AJAX frameworks or browser applications use special HTTP requests, which are permanently open in order to retrieve asynchronous data from the server. These requests may let the synchronization hang until the specified synchronization timeout expires. To prevent this situation, either use the HTML synchronization mode or specify the URL of the problematic request in the Synchronization exclude list setting.

To add the URL to the exclusion filter, specify the URL in the Synchronization exclude list in the Options dialog box.

Use a monitoring tool to determine if playback errors occur because of a synchronization issue. For instance, you can use FindBugs, http://findbugs.sourceforge.net/, to determine if an AJAX call is affecting playback. Then, add the problematic service to the Synchronization exclude list.

Note: If you exclude a URL, synchronization is turned off for each call that targets the URL that you specified. Any synchronization that is needed for that URL must be called manually. For example, you might need to manually add WaitForObject to a script or visual test. To avoid numerous manual calls, exclude URLs for a concrete target, rather than for a top-level URL, if possible.

Configuring Page Synchronization Settings

You can configure page synchronization settings for each individual visual test or script or you can set global options that apply to all visual tests and scripts in the Options dialog box. Choose Tools > Options expand Playback and click xBrowser to configure these options.

To configure individual settings for visual tests, record the visual test and then insert a Playback setting step to override the global playback value. Settings include: Synchronization exclude list, Synchronization mode, and Synchronization timeout.

For example, for visual tests, you might set the Synchronization mode playback setting to HTML and then return the Synchronization mode to AJAX for the remaining steps if necessary.

To configure individual settings for scripts, call any of the following:
  • Agent.SetOption(Options.XBrowserSynchronizationMode, mode)

    For the mode, type 1 to use HTML and 2 to use AJAX.

  • Agent.SetOption(Options.XBrowserSynchronizationExcludes, URL)

    Specify the URL or a fragment of the URL for any service or Web page that you want to exclude. For example, you might type http://example.com/syncsample/timeService.

  • Agent.SetOption(Options.XBrowserSynchronizationTimeout, time)

    Specify the time in milliseconds.