Sahi Pro - Assertions
Assertions compare runtime behaviour against expected behaviour.
Assertions are used for "verification" or "checking" of functionality
Assertions are used for "verification" or "checking" of functionality
Assertions are an integral part of Sahi scripts. A normal script would contain a series of actions followed by verification
of functionality.
_assert
_assert($condition[, $message])
Arguments
$condition | boolean | condition to verify |
$message | string optional | message to log if condition fails |
Details
_assert will do nothing if the condition passed to it is true
_assert will log failures to the playback logs if the condition evaluates to false.
_assert will do nothing if the condition passed to it is true
_assert will log failures to the playback logs if the condition evaluates to false.
danger
DO NOT USE THIS IN AN IF CONDITION as it does not return any value, and throws an exception if the assertion fails
_assertTrue
_assertTrue($condition[, $message])
Arguments
$condition | boolean | condition to verify |
$message | string optional | message to log if condition fails |
Details
Same as _assert
Same as _assert
_assertNotTrue
_assertNotTrue($condition[, $message])
Arguments
$condition | boolean | condition which is expected to evaluate to false |
$message | string optional | message to log if condition evaluates to true |
Details
_assertNotTrue will do nothing if the condition evaluates to false
_assertNotTrue will log failures to the playback logs if the condition evaluates to true.
_assertNotTrue will do nothing if the condition evaluates to false
_assertNotTrue will log failures to the playback logs if the condition evaluates to true.
danger
DO NOT USE THIS IN AN IF CONDITION as it does not return any value, and throws an exception if the assertion fails
_assertFalse
_assertFalse($condition[, $message])
Arguments
$condition | boolean | condition which is expected to evaluate to false |
$message | string optional | message to log if condition evaluates to true |
Details
_assertFalse will do nothing if the condition evaluates to false
_assertFalse will log failures to the playback logs if the condition evaluates to true.
_assertFalse will do nothing if the condition evaluates to false
_assertFalse will log failures to the playback logs if the condition evaluates to true.
danger
DO NOT USE THIS IN AN IF CONDITION as it does not return any value, and throws an exception if the assertion fails
_assertNull
_assertNull($value[, $message])
Arguments
$value | anything | Anything to be checked for null |
$message | string optional | message to log if value is not null |
Details
_assertNull will do nothing if the value passed is null
_assertNull will log failures to the playback logs if the value is not null.
_assertNull will do nothing if the value passed is null
_assertNull will log failures to the playback logs if the value is not null.
danger
DO NOT USE THIS IN AN IF CONDITION as it does not return any value, and throws an exception if the assertion fails
_assertNotNull
_assertNotNull($value[, $message])
Arguments
$value | anything | Anything to be checked for not null |
$message | string optional | message to log if value is null |
Details
_assertNotNull will do nothing if the value passed is not null
_assertNotNull will log failures to the playback logs if the value is null.
_assertNotNull will do nothing if the value passed is not null
_assertNotNull will log failures to the playback logs if the value is null.
danger
DO NOT USE THIS IN AN IF CONDITION as it does not return any value, and throws an exception if the assertion fails
_assertExists
_assertExists($element[, $message])
Arguments
$element | HTML DOM element | element to be checked for existence |
$message | string optional | message to log if element does not exist on page |
Details
_assertExists will do nothing if the element exists
_assertExists will log failures to the playback logs if the element does not exist
_assertExists will do nothing if the element exists
_assertExists will log failures to the playback logs if the element does not exist
danger
DO NOT USE THIS IN AN IF CONDITION as it does not return any value, and throws an exception if the assertion fails
_assertNotExists
_assertNotExists($element[, $message])
Arguments
$element | HTML DOM element | element to be checked for non existence |
$message | string optional | message to log if element exists on page |
Details
_assertNotExists will do nothing if the element does not exist
_assertNotExists will log failures to the playback logs if the element exists
_assertNotExists will do nothing if the element does not exist
_assertNotExists will log failures to the playback logs if the element exists
danger
DO NOT USE THIS IN AN IF CONDITION as it does not return any value, and throws an exception if the assertion fails
_assertEqual
_assertEqual($expected, $actual[, $message])
Arguments
$expected | any | Expected value. This value can be any normal javascript data type or an array Regular expressions can also be used. (eg. "/del/") |
$actual | any | Actual value. This value can be any normal javascript data type or an array. It is mostly some attribute of a HTML DOM element. |
$message | string optional | Message to be written to logs if the expected and actual values are not equal |
Details
_assertEqual will do nothing if the expected and actual values match
_assertEqual will log failures to the playback logs if the expected and actual values are not equal
_assertEqual will do nothing if the expected and actual values match
_assertEqual will log failures to the playback logs if the expected and actual values are not equal
danger
DO NOT USE THIS IN AN IF CONDITION as it does not return any value, and throws an exception if the assertion fails
_assertEqualArrays
_assertEqualArrays($expected, $actual[, $message])
Arguments
$expected | array | Expected array. |
$actual | array | Actual array. |
$message | string optional | Message to be written to logs if the expected and actual values are not equal |
Details
Asserts that expected and actual arrays are equal, else logs the message.
Asserts that expected and actual arrays are equal, else logs the message.
dangerDEPRECATED:
This is internally called by _assertEqual if expected and actual are arrays.
Use _assertEqual instead
This is internally called by _assertEqual if expected and actual are arrays.
Use _assertEqual instead
_assertNotEqual
_assertNotEqual($expected, $actual[, $message])
Arguments
$expected | any | Expected value. This value can be any normal javascript data type or an array Regular expressions can also be used. (eg. "/del/") |
$actual | any | Actual value. This value can be any normal javascript data type or an array. It is mostly some attribute of a HTML DOM element. |
$message | string optional | Message to be written to logs if the expected and actual values are equal |
Details
_assertNotEqual will do nothing if the expected and actual values do not match
_assertNotEqual will log failures to the playback logs if the expected and actual values are equal
_assertNotEqual will do nothing if the expected and actual values do not match
_assertNotEqual will log failures to the playback logs if the expected and actual values are equal
danger
DO NOT USE THIS IN AN IF CONDITION as it does not return any value, and throws an exception if the assertion fails
_assertContainsText
_assertContainsText($expected, $element[, $message])
Arguments
$expected | string | Expected string. Regular expressions can also be used. (eg. "/del/") |
$element | HTML DOM element | Element. We check if expected is a part of the text of this element. |
$message | string optional | Message to be written to logs if the expected string is not part of the text of given element |
Details
_assertContainsText will do nothing if the expected string/regex is part of the text content of given element
_assertContainsText will log failures to the playback logs if the expected string/regex is not part of the text content of given element
_assertContainsText will do nothing if the expected string/regex is part of the text content of given element
_assertContainsText will log failures to the playback logs if the expected string/regex is not part of the text content of given element
danger
DO NOT USE THIS IN AN IF CONDITION as it does not return any value, and throws an exception if the assertion fails
_assertNotContainsText
_assertNotContainsText($expected, $element[, $message])
Arguments
$expected | string | Expected string. Regular expressions can also be used. (eg. "/del/") |
$element | HTML DOM element | Element. We check if expected is not a part of the text of this element. |
$message | string optional | Message to be written to logs if the expected string is part of the text of given element |
Details
_assertContainsText will do nothing if the expected string/regex is not part of the text content of given element
_assertContainsText will log failures to the playback logs if the expected string/regex is part of the text content of given element
_assertContainsText will do nothing if the expected string/regex is not part of the text content of given element
_assertContainsText will log failures to the playback logs if the expected string/regex is part of the text content of given element
danger
DO NOT USE THIS IN AN IF CONDITION as it does not return any value, and throws an exception if the assertion fails