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.
Silk4J includes synchronization modes for HTML and AJAX.
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.
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.
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.
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.
desktop.setOption(CommonOptions.OPT_XBROWSER_SYNC_EXCLUDE_URLS, Arrays.asList("timeService"));