Debugging slowness - Using Diagnose

question Script steps seem to take forever. How can I debug this?
answer If a Sahi script waits for a long time without executing the next step, one can click on the Diagnose link on the Controller to dump the state of playback. It helps diagnose problems with Sahi indefinitely waiting for AJAX activity to subside.

Clicking on the Diagnose link lists the results of a few function calls that give us information about various components that may cause slowness.

The functions are: _sahi.areWindowsLoaded()

If this is false, it means that a page itself has not finished loading.

_sahi.areXHRsDone()

This indicates if all Ajax activity has subsided. Will be false if there are open XMLHttpRequests in readyStates 1,2 or 3.

_sahi.showOpenXHRs()

This will show all open XMLHttpRequests.

If you see XMLHttpRequests in readyState 1, do either of the following.
  • Add _setXHRReadyStatesToWaitFor("2,3") at the start of your script or *before* the step after which Sahi hangs.
  • OR if a lot of scripts have this problem, add the following to userdata\config\userdata.properties and restart Sahi server.
    xhr.wait_ready_states=2,3
_sahi.areFlexAppsLoaded(_sahi.top())

If this is false, it means that a swf file has not finished loading.

Diagnose does not return any results

If clicking Diagnose does NOT yield any results, press Pause in the Playback tab first. Then press Diagnose.