Verify Method

Class

Workbench.

Action

Verifies that the expected value equals the actual value and enables you to add a comment.

Syntax

This method has many variations:
result = Workbench.Verify(condition[, VerifyFlags])
or
result = Workbench.Verify(condition[, comment, VerifyFlags])
or
result = Workbench.Verify(expected, actual[, VerifyFlags])
or
result = Workbench.Verify(expected, actual[, VerifyFlags, comment])
Variable Description
result Whether the verification was successful. BOOLEAN.
condition The condition that needs to be met. BOOLEAN.
expected The value that you expect the script to return. OBJECT.
actual The actual value that the script returns. OBJECT.
comment Optional: The comment to include. STRING.
VerifyFlags Optional: Whether a screenshot should be captured if the verification fails. This is an enumeration with the following possible values:
  • None
  • ScreenShotOnFailure
VerifyFlags.

Examples

To compare the expected value with the actual value and add a comment, type:
Workbench.Verify(expected As Object, actual As Object, comment As String)

For example, Workbench.Verify("red", "green", "checking colors") fails with the message checking colors - Actual: [green]; Expected: [red].

To compare the expected value with the actual value, to add a comment, and to add a screenshot to the result file if the verification fails, type:
Workbench.Verify(expected As Object, actual As Object, comment As String, verifyFlags As VerifyFlags)

For example, Workbench.Verify("red", "green", "checking colors", verifyFlags.ScreenShotOnFailure) fails with the message checking colors - Actual: [green]; Expected: [red] and adds a screenshot to the result file.

To verify the value returned by the expected result and add a comment, type:
Workbench.Verify(condition As Boolean, comment As String)

For example, Workbench.Verify(True, "Test Passed") passes. While Workbench.Verify(False, "Test Failed") fails.

To verify the value returned by the expected result, to add a comment, and to add a screenshot to the result file if the verification fails, type:
Workbench.Verify(condition As Boolean, comment As String, verifyFlags As VerifyFlags)

For example, Workbench.Verify(True, "Test Passed", verifyFlags.ScreenShotOnFailure) passes and adds no screenshot. While Workbench.Verify(False, "Test Failed", ScreenShotOnFailure) fails and adds a screenshot to the result file.

To compare the actual value with the expected value for IEnumerable objects, such as lists and arrays, type:
Workbench.Verify(expectedEnumerable, actualEnumerable) 
For example:
Dim selectedItemsList = listBox.SelectedItems ' we assume that a list with the items "red" and "blue" is returned
Dim expectedItemsList = New List(Of String)()
expectedItemsList.Add("red")
expectedItemsList.Add("blue")

Workbench.Verify(selectedItemsList, expectedItemsList)  ' verification passes

Dim expectedItemsArray = New String() { "red", "blue" }
Workbench.Verify(selectedItemsList, expectedItemsArray) ' verification passes
Note: Two IEnumerable objects are considered equal if both have the same number of elements, and the elements are equal and in the same order.
Note: Mathematical operations with floating point numbers may lead to two numbers that are not completely identical because of their internal representation, although they should be equal from a user point of view. Therefore, floating point numbers (Double, Single) are considered equal if their difference is less than 0.00001. At times, this value may not be correct for the situation. In this case, compare the two values with the Verify(result As Boolean) instead.