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

Image-based validation example

The purpose of this chapter is to introduce and explain the concept of image-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: Image-based validation
    Time: Less than 30 min

    Download sample file

    Installation:

    Unzip the project directory to any folder on your computer
    Start Ranorex Studio and open the solution file ImagebasedValidation.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

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

    Start the demo application
    Switch to its image-based automation working environment
    Make the prepared image visible

    Verifying an image existance in the demo application

    Verifying an image existance in the demo application

    Verify that the image is displayed
    Exit the demo application

    Test preparation

    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. Record will start the test recording

    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

    Switch to Image-based automation working environment
    Make the prepared image visible by clicking the Show image checkbox

    Displaying demo application image

    Displaying demo application image

    Image-based validation

    The purpose of the test validation in this example is to verify, if the turned-on image in the demo application is displayed and if this image corresponds to the reference image during the specification of the test validation.

    Due to the fact, that the validation element is an image the validation is called image-based validation!

    Activate image-based validation

    Click Image based in the Recorder control center to activate image-based automation
    Click Validate to activate image-based validation mode and pause the current recording
    See the Ranorex Recorder in validation mode with image-based validation activated

    Activate image-based validation

    Activate image-based validation

    Select validation element

    Select the image in the demo application as validation element
    Selecting image-based validation element

    Selecting image-based validation 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 element

    Confirm the pre-selected validation element by clicking Next

    Confirm validation element

    Confirm validation element

    Important to know:

    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 & attributes

    • Here, all the attributes of the selected UI-element are displayed

    Screenshot of validation UI-element

    • Use the screenshot for a quick verification of the correct validation element selection

    Definition of validation attribute

    Specify the image-based validation and click OK when finished

    Specification of image-based validation

    Specification of image-based validation

    Important to know:

    The attribute specification for image-based validation outlines the validation image instead of validation attributes
    If necessary, a sub-image of the validation image can be specified
    Definition of the Image validation mode

    • None = de-activation of image-based validation mode
    • Contains = compares if the matched image is part of the validation image
    • Compare = compares if the matched image is the validation image

    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 specification with OK, Ranorex automatically continues recording where it had been paused when activating validation.

    Finalize & end recording

    Finalize & end recording

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

    Result

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

    Recording result of image-based validation example

    Recording result of image-based validation example

    Validation match operator

    • The operator defines the validation matching
    • Referring to image-based validation two operators ContainsImage and CompareImage
    Validation match operators for image-based validation

    Validation match operators for image-based validation

    Further reading

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

    Validation screenshot which will be matched against UI-element referred by corresponding repository item
    Repository item with reference to the UI-element to be validated

    Validation interpretation

    The validation is read / interpreted as follows:

    Image-based validation interpretation

    Image-based validation interpretation