Overview of Verifying an Objects State

Each class has a set of methods associated with it, including built-in verification methods. You can verify an object’s state using one of these built-in verification methods or by using other methods in combination with the built-in Verify function.

A class’s verification methods always begin with Verify. For example, a TextField has the following verification methods; VerifyPosition, VerifySelRange, VerifySelText, and VerifyValue.

You can use the built-in Verify function to verify that two values are equal and generate an exception if they are not. Typically, you use the Verify function to test something that does not map directly to a built-in property or method. Verify has the following syntax:
Verify (aActual, aExpected [, sDesc])
aActual
The value to verify. ANYTYPE.
aExpected
The expected value. ANYTYPE.
sDesc
Optional: A message describing the comparison. STRING.

Usually, the value to verify is obtained by calling a method for the object being verified; you can use any method that returns a value.

Example: Verify an object

This example describes how you can verify the number of option buttons in the Direction RadioList in the Replace dialog box of the Text Editor. There is no property or method you can directly use to verify this. But there is a method for RadioList, GetItemCount, which returns the number of option buttons. You can use the method to provide the actual value, then specify the expected value in the script.

When doing the verification, position the mouse pointer over the RadioList and press Ctrl+Alt. Click the Method tab in the Verify Window dialog box, and select the GetItemCount method.

Click OK to close the Verify Window dialog box, and complete your test case. Paste it into a script. You now have the following script:

testcase VerifyFuncTest ()
TextEditor.Search.Replace.Pick () 
Replace.Direction.GetItemCount () 
Replace.Cancel.Click () 
Now use the Verify function to complete the verification statement. Change the line:
Replace.Direction.GetItemCount ()
to
Verify (Replace.Direction.GetItemCount (), 2) 

That is, the call to GetItemCount (which returns the number of option buttons) becomes the first argument to Verify. The expected value, in this case, 2, becomes the second argument.

Your completed script is:

testcase VerifyFuncTest ()
TextEditor.Search.Replace.Pick () 
Verify (Replace.Direction.GetItemCount (), 2) 
Replace.Cancel.Click ()