This article uses a simple example to explain the concept of text-based validation. Before working with this example, make sure you are familiar with the basic concept of test validation.
To follow along with the steps in this chapter, download the sample solution file from the link below.
Theme: Text-based validation
Time: Less than 30 min
Install the sample solution
- Unzip to any folder on your computer.
- Start Ranorex Studio and open the solution file Introduction.rxsln
Test definition
Before we start recording our test, let’s define it. The test consists of 5 steps:
1. Open the Ranorex Demo Application.
2. In the Enter your name field, enter Harry and click Submit.
3. Verify that the welcome message changes accordingly.
4. Reset the welcome message.
5. Close the demo application and stop the recording.
Text-based validation
The purpose of the test validation in this example is to verify whether the interaction in step 2 of our test definition leads to the desired result, i.e., if the welcome message changes accordingly.
Because this requires validating the text contained in a UI element, we use text-based validation.
Activate validation
- Click Validate. Recording pauses and the Recorder switches to validation mode.
-
Select the UI element to validate:
- Move the mouse over the changed welcome message. A purple frame follows your mouse's movement.
- The purple frame indicates which element is currently selected for validation.
-
When the purple frame correctly highlights the welcome message, click it to select the element.
Confirm the validation element
3. To confirm the UI element, click Next.
- UI element location within GUI: The UI element tree shows where the element is located in the hierarchical structure of the application. You can correct your selection by choosing a different element here.
- UI element states and attributes: All the attributes of the selected UI element are displayed.
- Screenshot of validation UI element: Use the screenshot to quickly check whether you’ve selected the correct UI element.
Define validation attributes
- In the attribute list, ensure that Text selected as the validation attribute. Click OK to confirm.
- Text is selected as a validation attribute.
- Other attributes are available for validation.
Result
The finished recording contains five actions. Action 4 is the validation action.
- Validation action
-
Validation type operator: This operator defines which type of comparison is performed. Ranorex Studio offers nine different validation type operators:
- Validation attribute: Column #4 shows the attribute used for validation. In this example, the validation uses the Text attribute, but you can select other attributes from the drop-down list.
- Match value: The match value is the expected value for the selected attribute. It can be a constant (for example, a text string or number) or a variable.
- The linked repository item: Column #6 shows the repository item that the action is linked to, i.e. the UI element on which the validation is performed.
Interpreting the validation
Spelled out, the validation reads as follows:
If the Text attribute of the UI element referenced by LblWelcomeMessage is equal (AttributeEqual) to Welcome, Harry!, THEN the validation returns the value True.