In this article, you’ll learn attribute-based validation with a simple example. Before you begin, make sure you’re familiar with the basic concept of test validation.
Text-based validation is also a form of attribute-based validation, but it is covered in a separate article because it is the most frequently used type of validation.
To follow along with this tutorial, download the sample solution file from the link below.
Theme: Build a test
Time: 15 minutes
Install the sample solution
- Unzip to any folder on your computer.
-
Start Ranorex Studio and open the solution file
AttributeBasedValidation.rxsln
Test definition
Before you start recording, define what the test should do. In this example, the test consists of five steps:
- Open the Ranorex Studio Demo Application.
- Click the tab UI-element test area.
- In the radio button group box, click Green light.
- Verify that a green square appears next to the radio button.
- End the Demo Application and stop the recording.
Recording preparations
- Create a desktop test solution using the Solution Wizard.
- In step 2 of the setup, select the Ranorex Demo Application as your AUT.
When the Solution Wizard finishes, the Demo Application launches automatically when you start recording. Click the Recording1 tab to open the recording module.
Record the test
In Recording1, click RECORD. Ranorex Studio minimizes to the taskbar, and the Recorder control center shows the recording is active.
The application under test comes into focus.
In the radio button group box, click Green light.
Attribute-based validation
The goal of this validation is to verify that the square appears in the correct color after clicking the radio button. Since this requires validating a color attribute of a UI element, you’ll use attribute-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 green square. A purple frame follows your mouse movement.
- When the purple frame highlights the green square, click it to select the element.
- To confirm the UI element, click Next.
-
The selected validation element is a UI element with the role
Containerand theControlNamepnlColourPanel. - The screenshot of the selected UI element shows the green square.
-
The selected validation element is a UI element with the role
-
In the attribute list, select the attributes Exists (usually preselected) and BackColor, then click OK to confirm.
- The general attribute
Existsis usually preselected - The dynamic attribute
BackColorwith the valueGreenneeds to be selected
- The general attribute
Finish recording
After you confirm the validation, Ranorex Studio automatically continues recording. End the test by clicking Stop in the Recorder control center.
Result
After recording stops, Ranorex Studio returns to the main window. The actions table contains three actions Action 3 is the validation action.
- Validation action: The row representing the attribute-based validation.
-
Validation type operator: This operator identifies the type of validation to perform. Ranorex Studio offers nine different validation type operators.
- Validation attribute: This column displays the validation attribute. In this example, the validation uses the BackColor 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.
- Repository item: This column shows the repository item linked to the action, i.e., the UI element on which the validation is performed
Interpreting the validation
If written as a statement, the validation would read as follows:
If the attribute BackColor of the UI-element PnlColourPanel is EQUAL to the value Green, THEN the validation returns the value ‘True‘.