Skip to main content

Verify Functions

You can use verify functions to check ifthe certainsame conditions are met. The negative outcome of this verification can be user configured to just issue a warning, markas the executionassert asfunctions, abut failurethey oncedo wholenot script is completed or failabort the script at the momentstep. 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 verification.script.

This
configurationValueBehaviour on failure Fail (default)The script stops at the step that failed. FailAtEndThe script keeps running and the execution is donemarked usingas failed once the setAssertTypewhole functionsscript thatcompletes. receivesWarningOnly a warning is logged, the script continues, and the failure is not raised as parameteran error.
setAssertType("Warning");   // collect all verification warnings and keep the followingscript options:running
FailtAtEnd,setAssertType("FailAtEnd"); Fail,// 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 APIVerify equivalentChecks that assertTrue / assertFalseverifyTrue / verifyFalsea boolean is true / false assertExists / assertNotExistsverifyExists / verifyNotExiststhe element exists / does not exist assertEquals / assertNotEqualsverifyEquals / verifyNotEqualstwo values are equal / different assertNull / assertNotNullverifyNull / verifyNotNulla value is null / not null assertContainsTextverifyContainsTextan element contains the text or regular expression assertDoesNotContainTextverifyDoesNotContainTextan element does not contain the text or regular expression assertGreaterThan / assertLessThanverifyGreaterThan / verifyLessThana number is greater / lesser than another assertRangeverifyRangea 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.

    Related: Assert Functions, Assertions (function signatures).