Attribute-based validation example | Ranorex
Help CenterUser GuideRanorex Studio fundamentals

Attribute-based validation example

The purpose of this chapter is to introduce and explain the concept of attribute-based validation based on a simple example. Before working with this example, it is recommended that you make yourself familiar with the concept of test validation.

In this chapter

    Sample solution

    The complete sample solution can be downloaded and you are invited to experiment with the solution. Alternatively, you can follow the instructions below to build your own test solution.

    Training! What do I do?

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

    Download sample file

    Instruction:

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

    tipp icon

    Hint

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

    Test definition

    Attribute-based validation will be demonstrated along with an example with the demo application. The test is defined as follows:

    Start the demo application with the UI-element test area register pane
    Click the Green light radio button in the radio button group box
    Verify if the green pattern appears beside the button
    Close the demo application by clicking the Exit button
    Stop the recording
    Attribute-based example test definition

    Attribute-based example test definition

    Test preparation

    Follow the instructions herein to prepare the attribute-based validation example.

    Start Ranorex Studio and open a New test solution
    Give the solution a meaningful name and confirm with Create

    Recording preparation

    Before starting to record it is necessary to select the testing technology and to define the application under test.

    Technology & test application selection

    Technology & test application selection

    Click Record in the Recorder view of Ranorex Studio
    Click Desktop for testing a desktop application

    Selecting the application under test

    Selecting the application under test

    Click Add app… for adding an application
    Use the explorer dialog to search for your application to be tested. In this example, we choose the demo application in the /Downloads/ folder
    Select the program icon RxDemoApp.exe and click Open. The application appears in the selection dialog

    Recording the test – part I

    tipp icon

    Hint

    Remember that all user interactions are recorded once the Recorder is started.

    • Clicking Pause stops recording, Continue proceeds with recording again
    • Stop ends the recording

    Details about the Recorder control center are summarized in > Ranorex Studio fundamentals > Ranorex Recorder > ⇢ Recorder control center & hotkeys.

    Start the recording. Ranorex Studio disappears into the background. The Recorder control center indicates active recording

    Starting the test recording

    Starting the test recording

    The demo application comes into front. Click UI-element test area
    Click the radio button Green light

    Clicking a radio button in the demo application

    Clicking a radio button in the demo application

    Attribute-based validation

    The purpose of the test validation in this example is to verify if the color field which appears after clicking the radio button is displayed in the color ‘Green’.

    Due to the fact, that the validation element is a color attribute, the validation is called attribute-based validation!

    Activate validation

    Click Validate to pause recording and start the specification of test validation

    Activate validation

    Activate validation

    Select validation element (attribute)

    Select the green colored UI-element (rectangle) as validation element

    Select validation UI-element

    Select validation UI-element

    Important to know:

    • Move the mouse to the validation element of your choice
    • A purple frame follows the mouse movement and ‘grabs’ UI-elements on its way
    • Once you achieve the proper selection – click it!

    Confirm validation UI-element

    Confirm the pre-selected validation element by clicking Next

    Confirm validation UI-element

    Confirm validation UI-element

    Important to know:
    See the selected validation UI-element:

    • The UI-element is assigned the role Container and …
    • … has the ControlName ‘pnlColourPanel’

    See the screenshot of the selected UI-element with the green rectangle

    Definition of validation attribute

    Specify the validation attribute and confirm with clicking OK

    Specify validation attribute

    Specify validation attribute

    Important to know:

    The general attribute Exists is preselected per default
    Additionally select the dynamic attribute BackColor='Green' as validation attribute down the attribute list

    Recording the test – part II

    After specifying the validation action, Ranorex automatically continues the recording. You now need to finalize and end the test recording. Follow the instructions below.

    tipp icon

    Hint

    After confirming the validation attribute definition with OK, Ranorex automatically continues recording where it had been paused when activating validation.

    Finalize & end recording

    Finalize & end recording

    Click the Exit button of the demo application
    Click Stop in the Recorder control center to end recording

    Result(s):

    The result is a recording module with 5 recorded actions where action #4 is the validation action.

    Recording result of attribute-based validation example

    Recording result of attribute-based validation example

    Action #4 is the validation action
    Validation match operator

    • This operator defines the matching
    • 9 different matching operators are available
    Validation match operators

    Validation match operators

    Further reading

    A detailed description of all validation match operators can be found in > Ranorex Studio fundamentals > Actions > ⇢ Detailed list of actions.

    Validation attribute:

    • Column #4 outlines the validation attribute
    • In the current example, the BackColor attribute was specified
    • A drop-down list makes all available validation attributes selectable

    Match value:

    • The match value can be a constant (i.e. text, number, …)
    • It can also be a variable holding the match value

    Repository item:

    • Finally, column #6 outlines the reference to the validation repository item selected

    Validation interpretation

    The validation is read / interpreted as follows:

    IF the attribute ‘BackColor’ of the UI -element referenced by ‘PnlColourPanel’ is EQUAL TO the value ‘Green’ THEN the validation returns the value ‘True’