Attribute-based validation example
In this chapter, we’ll demonstrate the concept of attribute-based validation based on a simple example. Before working with this example, make sure you’re familiar with the ⇢ basic concept of test validation.
Of course, ⇢ text-based validation is also an example for attribute-based validation, but we’ve dedicated a separate chapter to it because it’s probably the most frequent type of validation.
In this chapter
Download the sample solution
To follow along with this tutorial, download the sample solution file from the link below.
Install the sample solution:
Unzip to any folder on your computer.
Start Ranorex Studio and open the solution file
Before we start recording our test, let’s define it. The test consists of 5 steps:
1. Open the Ranorex Studio Demo Application.
2. Click the tab UI-element test area.
3. Click the radio button Green light in the radio button group box.
4. Verify that a green square appears next to the radio button.
5. End the Demo Application and stop the recording.
Attribute-based example test definition
Before recording any steps, choose your testing technology and add the application under test (AUT).
In the Recorder view of Ranorex Studio, click RECORD.
Click Desktop, because the Ranorex Demo Application is a desktop application.
Selecting the application under test (AUT)
In the Explorer dialog that appears, browse to where you saved the Demo Application.
Select the program file
RxDemoApp.exeand click Open.
Record the test: part one
- Click Pause to pause recording. Click Continue to resume recording.
- Click Stop to end recording.
Learn more about the Recorder control center in Ranorex Studio fundamentals > Ranorex Recorder > ⇢ Recorder control center & hotkeys.
Read about whitelisting in Ranorex Studio fundamentals > ⇢ Whitelisting.
The Recorder control center shows that recording is active.
Starting the test recording
The application under test comes into focus.
In the radio button group box, click the radio button Green light.
The purpose of the test validation in this example is to verify whether a colored square appears in the correct color after clicking the radio button.
Since this requires us to validate the color attribute of a UI element, we’re carrying out an attribute-based validation.
Let’s go through the steps:
Click Validate. Recording pauses and the Recorder switches to validation mode.
Select validation element
Select the UI element to validate:
- Mouse over the green square. A purple frame follows your mouse movement.
- The purple frame indicates which element is currently selected for validation.
- Once your selection matches the green square, click it.
Confirm validation element
To confirm the UI element, click Next.
The selected validation element:
- The UI element has the role
The screenshot of the selected UI element, showing the green square.
Define validation attributes
Select the attributes Exists (usually preselected) and BackColor and click OK to confirm.
The general attribute
Exists is usually preselected.
The dynamic attribute
BackColor with the value
Green needs to be selected.
Recording the test – part II
Once you’ve finished the validation action, Ranorex automatically continues recording. The next step is to finalize and end the test recording.
Click the Exit button of the Demo Application.
In the Recorder control center, click Stop to end the recording.
Once you’ve stopped recording, you’ll be returned to Ranorex Studio. You’ll see the actions table with 5 recorded actions. Action #4 is the validation action.
Recording result of attribute-based validation example
The validation action
Validation type operator
- This operator defines what type of validation will be carried out.
- There are 9 different validation type operators.
Validation type operators
- Column #4 shows the validation attribute.
- In our example, this is the BackColor attribute.
- You can select other attributes from the drop-down menu.
- The match value can be a constant (i.e. text, number, etc.) or a variable.
- Column #6 shows the repository item 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 attribute BackColor of the UI element PnlColourPanel is EQUAL TO the value Green, THEN the validation returns the value True.