Verify Functions
Verify functions check the same conditions as the assert functions, but they do not abort the script at the step. A failed verification is recorded, and what happens next is decided by the assert type set for the run.
setAssertType(value)
Sets the behaviour applied when an assert or verify fails. It applies to the rest of the script.
| Value | Behaviour on failure |
|---|---|
Fail (default) | The script stops at the step that failed. |
FailAtEnd | The script keeps running and the execution is marked as failed once the whole script completes. |
Warning | Only a warning is logged, the script continues, and the failure is not raised as an error. |
setAssertType("Warning"); // collect all verification warnings and keep the script running
setAssertType("FailAtEnd"); // keep running, but fail the run at the end
setAssertType("Fail"); // default: stop at the failed step
Verify APIs
The verify set mirrors the assert set: every assert API has a verify equivalent with the same parameters, and it can be used anywhere a statement is accepted — including inside a branch or a loop, where an assert would stop the playback.
| Assert API | Verify equivalent | Checks that |
|---|---|---|
assertTrue / assertFalse | verifyTrue / verifyFalse | a boolean is true / false |
assertExists / assertNotExists | verifyExists / verifyNotExists | the element exists / does not exist |
assertEquals / assertNotEquals | verifyEquals / verifyNotEquals | two values are equal / different |
assertNull / assertNotNull | verifyNull / verifyNotNull | a value is null / not null |
assertContainsText | verifyContainsText | an element contains the text or regular expression |
assertDoesNotContainText | verifyDoesNotContainText | an element does not contain the text or regular expression |
assertGreaterThan / assertLessThan | verifyGreaterThan / verifyLessThan | a number is greater / lesser than another |
assertRange | verifyRange | a number falls between a minimum and a maximum |
The reference also lists a Validate call alongside the verify APIs.
Example
navigateTo("http://demosite.appvance.com/");
wait(1000);
setAssertType("Warning");
verifyExists(span("Products[1]"));
verifyContainsText(span("Products[1]"), "Ruby");
verifyTrue(isVisible(link("Clothing")));
// the script continues even when one of the checks above fails,
// and the failures are reported with the run
Choosing between assert and verify
- Assert when the next step depends on the condition — if the cart is not there, clicking Checkout is meaningless.
- Verify when you want the evidence recorded but the run should keep going and produce the full picture.