Synchronize script steps

This topic describes the process of synchronizing steps in TruClient Scripts.


You can add synchronization functions to match the execution of the TruClient script with the output from your application.

Synchronization points allow the script to pause in the replay while waiting for an object, a window, a dialog, or another type of control to appear based on a specified condition.

By adding a JavaScript synchronization code logic, you can accurately capture the response times based on asynchronous events.

Back to top

How to synchronize script steps

  1. Interactively record the business process.

    A step action does not always have to run to completion before the next step starts. Each step has an End Event that defines the point at which subsequent steps are allowed to start running. After the interactive recording, each End Event is set to Automatic: Not Yet Set.

  2. Identify the End Event.

    Before enhancing a TruClient script, replay the script to synchronize the steps. During the first script replay on a particular browser, TruClient will try to automatically identify the End Event for each step.

    An End Event can be one of the following:

    • Automatic: Not Yet Set. The automatic end event has not yet been determined.

    • Automatic: Timers Ended. The automatic end event whenever TruClient identifies either the setTimeout() or the setInterval() function running as part of the document load in the JavaScript code.

      Note: This feature has been deprecated. It is supported in TruClient scripts recorded in older versions, but not for new scripts.

    • Action Completed. Step ends when its action is completed. An example of an action is a button click.

    • DOM content loaded. Step ends when the page's Document Object Model (DOM) is ready. This means that the API for interacting with the content, style, and structure of a page is ready to receive requests from your application's client side code.

    • Step synchronous network completed. Step ends when all HTTP requests have been completed excluding requests that are associated with open connections that are not relevant to the step. Usually, these requests are triggered by using XMLHttpRequest.

    • Document Loaded. Step ends when the process of loading a document is completed. This means that all scripts and stylesheets have finished loading and have been executed, and all images have been downloaded and displayed.

    • Object Exists. Step ends when the end event object is visible on the screen.

      For TruClient Web and TruClient Mobile Web scripts, this end event must be selected manually in the step.

      For TruClient Native Mobile scripts, this end event is automatically identified during the first replay. For more information, see Enhance scripts.

      Note: There is no distinct timeout for the object selected in the End Event; the timeout is based on the Step Timeout value.

    • Step network completed. Step ends when all HTTP requests have completed including requests initiated by XMLHttpRequest.

    • Dialog opened. Step ends when a dialog box is opened.

  3. Confirm the End Event.

    If there is an end event timeout failure in the second replay , you should determine if another end event should be assigned to the step that timed out. If so, replace the end event manually.

    If you change the end step manually, the change is applied to all browsers, overwriting the automatic setting. If you need a different end event for each browser and you have manually changed an end event, use an If Browser step. See Troubleshooting issues replaying a script across browsers.

Note: You may need to replay the script several times until all steps have been accurately synchronized.

If synchronization works on one browser but not on all, see Replaying on all browsers.

Back to top

See also: