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

    tipp icon


    The screencast “Attribute-based validation” walks you through the information found in this chapter.:

    Watch the screencast now

    Download the sample solution

    To follow along with this tutorial, download the sample solution file from the link below.

    Sample solution

    Theme: Build a test
    Time: 15 minutes

    Download sample file

    Install the sample solution:

    Unzip to any folder on your computer.
    Start Ranorex Studio and open the solution file AttributeBasedValidation.rxsln

    tipp icon


    The sample solution is available for Ranorex versions 8.0 or higher. You must agree to the automatic solution upgrade for versions 8.2 and higher.

    Test definition

    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

    Attribute-based example test definition

    Recording preparations

    Create a desktop-test solution using the Solution Wizard and in step 2 of the setup, select the Demo Application as your AUT.

    Demo App selected as AUT and is launched automatically when you start recording.

    When the Solution Wizard has finished, click the Recording1 tab in the Ranorex Studio working environment.

    Record the test: part one

    tipp icon


    Remember, if you’re not using whitelisting, all user interactions are captured once recording has started, even if they are not performed on the AUT.

    • 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.

    In the recording module view of Recording1, click RECORD. Ranorex Studio is minimized to the taskbar automatically.
    The Recorder control center shows that recording is active.

    Starting the test recording

    Starting the test recording

    The application under test comes into focus.
    In the radio button group box, click the radio button Green light.
    Clicking a radio button in the demo application

    Attribute-based validation

    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:

    Activate validation

    Click Validate. Recording pauses and the Recorder switches to validation mode.

    Activate validation

    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.
    Select validation UI-element

    Confirm validation element

    To confirm the UI element, click Next.

    Confirm validation UI-element
    The selected validation element:

    • The UI element has the role Container and the ControlName pnlColourPanel

    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.

    Specify validation attribute
    The general attribute Exists is usually preselected.
    The dynamic attribute BackColor with the value Green needs to be selected.

    Finish recording

    Once you’ve finished the validation action, Ranorex automatically continues recording. The next step is to end the test recording.

    Finalize & end recording
    In the Recorder control center, click Stop to end the recording.


    After recording stops, you are returned to Ranorex Studio. The actions table contains three recorded actions. Action #3 is the validation. 

    Recording result of attribute-based validation example

    Recording result of attribute-based validation example

    The validation action
    Validation type operator

    • This operator identifies the type of validation to perform.
    • There are nine different validation type operators.
    Validation match operators

    Validation type operators

    Further reading

    A detailed description of all validation match operators can be found in Ranorex Studio fundamentals > Actions > ⇢ Action properties.


    Validation attribute:

    • This column displays the validation attribute.
    • In our example, this is the BackColor attribute.
    • You can select other attributes from the drop-down menu.

    Match value:

    • The match value can be a constant (i.e. text, number, etc.) 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‘.