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

Silk4J 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, Silk4J 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, Silk4J does not wait for the Flash object to complete its calculations. For example, you might use 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.

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 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 test or you can set global options that apply to all tests in the Script Options dialog box.

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

To configure individual settings for tests, record the test and then insert code to override the global playback value. For example, to exclude the time service, you might type:
desktop.setOption(CommonOptions.OPT_XBROWSER_SYNC_EXCLUDE_URLS, 
    Arrays.asList("timeService"));
  • OPT_XBROWSER_SYNC_MODE
  • OPT_XBROWSER_SYNC_EXCLUDE_URLS
  • OPT_SYNC_TIMEOUT