APIs used in Debugging Sahi Scripts
Some APIs are good for debugging Sahi scripts. They are mostly removed once debugging is done.
Modes BrowserWindowsJavaAndroidiOSSAP
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.
Parameters
| Name | Type | Description |
|---|---|---|
$message | string | Message to write to Sahi console |
Raw script
// Example:
_debug("Current count is " + $i);Sahi Pro Classic API _debug
Debug To Err
Section titled “Debug To Err”Modes BrowserWindowsJavaAndroidiOSSAP
Same as _debug, but prints to the error stream.
Parameters
| Name | Type | Description |
|---|---|---|
$message | string | Message to write to Sahi console error stream |
Sahi Pro Classic API _debugToErr
Debug To File
Section titled “Debug To File”Modes BrowserWindowsJavaAndroidiOSSAP
Prints the message into a file for debugging purposes.
Parameters
| Name | Type | Description |
|---|---|---|
$message | string | Message to write to file |
$filePath | string | Path to file. Relative path resolves relative to files folder of the current project. |
Sahi Pro Classic API _debugToFile
Modes BrowserWindowsJavaAndroidiOSSAP
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.
Parameters
| Name | Type | Description |
|---|---|---|
None |
Sahi Pro Classic API _pause
Modes Browser
Alerts the message on the browser. This allows a very handy, interactive way of debugging scripts.
Parameters
| Name | Type | Description |
|---|---|---|
$message | string | Message to be alerted on browser. |
Raw script
//Example:_alert("Current count is " + $i);Sahi Pro Classic API _alert
Confirm
Section titled “Confirm”Modes Browser
Brings up a javascript confirm dialog with given message. Use only while debugging.
Parameters
| Name | Type | Description |
|---|---|---|
$message | string | Message to confirm |
Sahi Pro Classic API _confirm
Prompt
Section titled “Prompt”Modes Browser
Brings up a javascript prompt with given message. Use only while debugging.
Parameters
| Name | Type | Description |
|---|---|---|
$message | string | Message to prompt |
Sahi Pro Classic API _prompt
Highlight
Section titled “Highlight”Modes BrowserWindowsJavaAndroidiOSSAP
Highlights an element with a red border. Used for debugging purposes.
Parameters
| Name | Type | Description |
|---|---|---|
$element | HTML DOM element | Element to highlight |
Sahi Pro Classic API _highlight

