Sahi Pro - Script Suite Info APIs

_scriptName

Since Sahi Pro: 3.5
Since Sahi OS: 2

_scriptName()

Arguments
None

Details

Returns the script name.
// In script D:/sahi/userdata/scripts/demo/check.sah
var $scriptName = _scriptName(); // returns "check.sah"

_scriptPath

Since Sahi Pro: 3.5
Since Sahi OS: 2

_scriptPath()

Arguments
None

Details

Returns the full script file path.
// In script D:/sahi/userdata/scripts/demo/check.sah
var $_scriptPath = _scriptPath(); // returns "D:/sahi/userdata/scripts/demo/check.sah"

_scriptStartTime

Since Sahi Pro: 4.3
Since Sahi OS: 4.3

_scriptStartTime()

Arguments
None

Details

Returns script startTime as a Date object
danger In versions prior to 6.0.0, it returned a String. Scripts written before 6.0.0 will need changes.
var $dateObj = _scriptStartTime();
# Detailed usage:
var $date = $dateObj.toString();
var $year = $dateObj.getFullYear();
var $month = $dateObj.getMonth(); // Month range 0-11
var $month = $dateObj.getMonth2(); // Month range 1-12
var $day = $dateObj.getDay();
var $hours = $dateObj.getHours();
var $minutes = $dateObj.getMinutes();
var $seconds = $dateObj.getSeconds();

_scriptStatus

Since Sahi Pro: 3.5
Since Sahi OS: 3

_scriptStatus()

Arguments
None

Details

Returns "SUCCESS" or "FAILURE"

_userDataDir

Since Sahi Pro: 3.5
Since Sahi OS: 3

_userDataDir()

Arguments
None

Details

Returns full file path of userdata directory

_userDataPath

Since Sahi Pro: 3.5
Since Sahi OS: 3

_userDataPath($relPath)

Arguments
$relPathstring Path to resolve relative to userdata path

Details

Returns full file path of file resolved relative to userdata directory
// If you have a data/excelsheets folder in sahi/userdata folder, you can access it
// using
$excelDataPath = _userDataPath("data/excelsheets");
// returns D:/sahi/userdata/data/excelsheets

_resolvePath

Since Sahi Pro: 3.5
Since Sahi OS: 3.5

_resolvePath($relPath)

Arguments
$relPathstring Path to resolve relative to current script path

Details

Returns full file path of file resolved relative to current script path
/*
If the current script is
D:/sahi/userdata/scripts/user/login.sah
If you have common csv file in
D:/sahi/userdata/scripts/common/user.csv
*/
// using
$csvPath = _resolvePath("../common/user.csv");
// returns D:/sahi/userdata/scripts/common/user.csv

_sessionInfo

Since Sahi Pro: 3.5
Since Sahi OS: 3

_sessionInfo()

Arguments
None

Details

Returns information about the current session as an associative array.
The object has attributes:

  • isRecording: returns true if recording
  • isPlaying: returns true if playingback
  • isPaused: returns true if playback is paused
  • sessionId: returns Sahi's sessionId
  • threadNumber: returns the threadNumber of browser instance running
  • scriptPath: returns script path of current script. Same as _scriptPath()

var $sessionInfo = _sessionInfo();
var $sessionId = $sessionInfo["sessionId"];
// or
var $sessionId = $sessionInfo.sessionId;

_suiteInfo

Since Sahi Pro: 3.5
Since Sahi OS: 3

_suiteInfo()

Arguments
None

Details

Returns suite information as an associative array.
Some of the properties in the array are:
  • suiteReportId: The suite report id for the suite/script run
  • suiteName: Name of suite/script
  • suitePath: Path of suite/script
  • baseURL: Base url for suite/script run
  • browserType: Browser that the suite/script was run on

var $suiteInfo = _suiteInfo();
var $name = $suiteInfo["suiteName"];
// or
var $name = $suiteInfo.suiteName;

_testcasesInfo

Since Sahi Pro: 6.1.0
Since Sahi OS: NA

_testcasesInfo()

Arguments
None

Details

Returns an array of testcase-property objects of the testcases in the script that have already been executed.
A testcase-property is an associative array with the following attributes:
  • id: testcase Id, Unique identifier for testcase
  • description: Description for testcase
  • status: Execution status of the testcase

var $tcs = _testcasesInfo();
for(var $i=0; $i<$tcs.length; $i++){
  var $tc = $tcs[$i];
  _log("id = " + $tc.id + "; description = " + $tc.description + "; status = " + $tc.status + ";");
}

_isDataPassed

Since Sahi Pro: 5.1.0
Since Sahi OS: NA

_isDataPassed()

Arguments
None

Details

Returns true if data has been passed via a dd.csv data driven suite.
More details here