Text-based validation example | Ranorex Studio User Guide
Help CenterUser GuideRanorex Studio fundamentals

Text-based validation example

This chapter uses a simple example to explain the concept of text-based validation. Before working with this example, make sure you’re familiar with the ⇢ basic concept of test validation.

In this chapter

    Download the sample solution

    To follow along with the steps in this chapter, download the sample solution file from the link below.

    Sample solution

    Theme: Text-based validation
    Time: Less than 30 min

    Download sample file

    Install the sample solution:

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

    tipp icon

    Hint

    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 Demo Application.

    2. In the “Enter your name” field, enter Harry and click Submit.

    Changing welcome message in demo application

    3. Verify that the welcome message changes accordingly.

    4. Reset the welcome message.

    5. End 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. Since this requires us to validate the text contained in a text field, we’re carrying out a text-based validation.

    Let’s go through the steps:

    Activate validation

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

    Activate text-based validation

    Select validation element

    Select the UI element to validate:

    • Mouse over the changed welcome message. A purple frame follows your mouse movement.
    • The purple frame indicates which element is currently selected for validation.
    • Once your selection matches the welcome message, click it.
    Selecting text-based validation element

    Confirm validation element

    To confirm the UI element, click Next.

    Confirm validation element

    UI element location within GUI

    • Here you can correct the previous choice by selecting any other UI element for validation.
    • The UI element tree represents the hierarchical GUI structure of the application.

    UI element states and attributes

    • Here, 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

    The attribute Text is usually preselected. If it isn’t, select it. Click OK to confirm.

    Definition of validation attribute

    Text is selected as validation attribute.
    Other attributes available for validation.

    Note icon

    Note

    All attributes and states that describe and define a UI element can be used in validations. You can also validate several attributes and states at once to make a validation more specific.

    Result

    The finished recording contains seven actions. Action #5 is the validation action.

    Recording result of text-based validation example

    Recording result of text-based validation example

    Validation action
    Validation type operator

    • This operator defines what type of validation will be carried out.
    • There are 9 different validation type operators.
    Validation match operators

    Validation type operators.

    Further reading

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

    Validation attribute

    • Column #4 shows the validation attribute.
    • In our example, this is the Text 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.

    The linked repository item

    • 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 Text attribute of the UI element referenced by LblWelcomeMessage is equal (AttributeEqual) to “Welcome, Harry!“, THEN the validation returns the value True.