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
Section titled “Start Documentation”Modes BrowserWindowsJavaAndroidiOSSAP
Start Documentation starts the documentation. All steps after this line will be documented until a _stopDocumentation call is made.
Parameters
| Name | Type | Description |
|---|---|---|
$filepath | string | File path of the output Sahi script containing documentation with screenshots. Relative path resolves relative to files folder of the current project. |
$overwrite | booleanoptional | If true, overwrites content. Default is false, which appends at the end of existing content. |
$refFile | stringoptional | 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 as HTML and use it as a reference file. 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. |
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
Section titled “Stop Documentation”Modes BrowserWindowsJavaAndroidiOSSAP
Stop Documentation will stop the documentation.
Parameters
| Name | Type | Description |
|---|---|---|
None |
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

