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.

Start Documentation

Start Documentation 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. Start Documentation("doc2.sah", true, "reference_doc.sah");

doc2.sah will be a copy of reference_doc.sah except for the updated screenshots.

Parameters
$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.
Return Value

Modes Supported :
Raw Script
_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"));

Sahi Pro Classic API :_startDocumentation


Stop Documentation

Stop Documentation will stop the documentation.

Parameters
None
Return Value

Modes Supported :
Raw Script
_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"));

Sahi Pro Classic API :_stopDocumentation