Documentation APIs

Sahi As Documentation Tool describes how to create documentation while recording a new Sahi script.

But what if we wanted to create documentation for previously created scripts?

Sahi's Documentation APIs allow you to do just that.

Use the _startDocumentation and _stopDocumentation APIs in your script, and execute the script to create documentation with screenshots.

_startDocumentation

Since: Sahi ProDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
6.0.07.0.07.5.09.0.0NA

Available for modes: Browser | Windows | Java | Android | iOS | SAP

_startDocumentation($filepath[, $overwrite[, $refFile]])

Arguments
$filepathstring
File path of the output Sahi script containing documentation with screenshots.
File path of the output Sahi script containing documentation with screenshots. Relative path resolves relative to files folder of the current project.
$overwriteboolean optionalIf true, overwrites content. Default is false, which appends at the end of existing content.
$refFilestring optional
File path of the reference sahi document script. This parameter will change the Sahi document's description and screenshots accordingly.
File path of the reference sahi document script. This parameter will change the Sahi document's description and screenshots accordingly. Relative path resolves relative to files folder of the current project.
The modification to this file will work as the reference to the next version of the document. To create the reference file, do the following,

1. If you have recorded the script in documentation mode, export this doc file and use as a reference file.
Refer to the "Export as HTML" content in the Viewing and Editing Document for how to export the document.

2. If you have not recorded the script in documentation mode, use the below statement in your script,
_startDocumentation("sourceFile.sah", true);
This will create sourceFile.sah (script with documentation and screenshots) on first playback. Use this as your reference file.

Returns
null

Sahi Pro Flowcharts Action :Start Documentation

Details

_startDocumentation starts the documentation. All steps after this line will be documented until a _stopDocumentation call is made.

info When to use $refFile: Suppose you had already created a documentation using this API (say reference_doc.sah) and edited it. You may have modified descriptions and deleted some unnecessary screenshots. When your application screens change, you may want to just recapture the screenshots but leave the descriptions intact.

To create an updated version of this document with updated screenshots, pass reference_doc.sah as the $refFile. _startDocumentation("doc2.sah", true, "reference_doc.sah");

doc2.sah will be a copy of reference_doc.sah except for the updated screenshots.
_focusWindow();
// This is needed since we need screenshots of the application window.

_startDocumentation("doc.sah", true, "reference_doc.sah");
// doc.sah is the desired output script that contains the documented Sahi steps with screenshots.

_navigateTo("http://sahi.co.in/demo/training/");
_setValue(_textbox("user"), "test");
_setValue(_password("password"), "secret");
_click(_submit("Login"));
_assertVisible(_textbox("total"));
_stopDocumentation(); // Documentation stopped
_click(_button("Logout"));
danger When steps are executed and documented, the screenshots have to be taken for the main application window. Hence we need to call _focusWindow before _startDocumentation to bring the application window into focus.


_stopDocumentation

Since: Sahi ProDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
6.0.07.0.07.5.09.0.0NA

Available for modes: Browser | Windows | Java | Android | iOS | SAP

_stopDocumentation()

Arguments
None

Returns
null

Sahi Pro Flowcharts Action :Stop Documentation

Details

_stopDocumentation will stop the documentation.

_startDocumentation("doc.sah"); //Documentation started
_navigateTo("http://sahi.co.in/demo/training/");
_setValue(_textbox("user"), "test");
_setValue(_password("password"), "secret");
_click(_submit("Login"));
_assertVisible(_textbox("total"));
_stopDocumentation(); // Documentation stopped
_click(_button("Logout"));