Sahi Pro - APIs used in Debugging Sahi Scripts


abstract Some APIs are good for debugging Sahi scripts. They are mostly removed once debugging is done.

_debug

Since Sahi Pro: 3.5
Since Sahi OS: 2

_debug($message)

Arguments
$messagestring Message to write to Sahi console

Details

Debug messages are written in the Sahi console and not in the playback logs.
It is useful when correlating to messages appearing on the Sahi console.

Example:

_debug("Current count is " + $i);

_debugToErr

Since Sahi Pro: 3.5
Since Sahi OS: 2

_debugToErr($message)

Arguments
$messagestring Message to write to Sahi console error stream

Details

Same as _debug, but prints to the error stream.

_debugToFile

Since Sahi Pro: 3.5
Since Sahi OS: 2

_debugToFile($message, $filePath)

Arguments
$messagestring Message to write to file
$filePathstring Path to file. Relative path resolves relative to where Sahi's process is started from.

Details

Prints the message into a file for debugging purposes.

_pause

Since Sahi Pro: 5.1.0
Since Sahi OS: NA

_pause()

Arguments
None

Details

Runs the script till that point and pauses execution. Acts like a debugger breakpoint.
Further playback can be controlled from the Controller Playback tab via Step or Play buttons.
warningDO NOT leave this in a production script, since it needs user input to proceed and will halt execution

_alert

Since Sahi Pro: 3.5
Since Sahi OS: 2

_alert($message)

Arguments
$messagestring Message to be alerted on browser.

Details

Alerts the message on the browser. This allows a very handy, interactive way of debugging scripts.

Example:

_alert("Current count is " + $i);
warningDO NOT leave this in a production script, since it needs user input to proceed and will halt execution

_confirm

Since Sahi Pro: 3.5
Since Sahi OS: 3.5

_confirm($message)

Arguments
$messagestring Message to confirm

Details

Brings up a javascript confirm dialog with given message. Use only while debugging.

_prompt

Since Sahi Pro: 3.5
Since Sahi OS: 2

_prompt($message)

Arguments
$messagestring Message to prompt

Details

Brings up a javascript prompt with given message. Use only while debugging.

_highlight

Since Sahi Pro: 3.5
Since Sahi OS: 2

_highlight($element)

Arguments
$elementHTML DOM element Element to highlight

Details

Highlights an element with a red border. Used for debugging purposes.