This chapter contains a simple tutorial for image-based validation. Before working with this example, make sure you’re familiar with the ⇢ basic concept of test validation.
In this chapter
To follow along with this tutorial, download the sample solution file from the link below.
Theme: Build a test
Time: 15 minutes
Unzip to any folder on your computer.
Start Ranorex Studio and open the solution file
Before you start recording, let’s define the test. It consists of 5 steps:
1. Start the demo application.
2. Click the Image-based automation tab.
3. Make the image visible.
4. Verify that the image is displayed.
5. Exit the Demo Application.
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.
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.
The application under test comes into focus. Click the tab Image-based automation.
To make the image appear, click the checkbox Show image.
The goal of the example validation is to verify whether the image of the cat appears when the checkbox is selected. Since this requires us to validate an image, it’s an image-based validation.
Follow the steps below:
In the Recorder controls, activate the switch Image based recording.
Click Validate. The Recorder pauses recording and switches to image-based validation mode.
Select the UI element to validate:
To confirm the UI element, click Next.
UI element location within GUI
UI element states and attributes
Screenshot of validation UI element
Define the image that will be used for the validation. For our example, simply leave everything as it is and click OK to confirm.
The Image tab is selected in the validation dialog instead of the Attributes tab.
Draw a rectangle to select a part of the image when using the “Contains” validation mode.
Different image validation modes are available:
Once you’ve finished the validation action, Ranorex automatically continues recording. The next step is to end the test recording.
In the Recorder control center, click Stop to end the recording.
After recording stops, you are returned to Ranorex Studio. You’ll see the actions table with three recorded actions. Action #3 is the validation action.
Validation type operator
A detailed description of all validation match operators can be found in > Ranorex Studio fundamentals > Actions > ⇢ Action properties.
The validation screenshot to which the actual image found during testing will be matched.
The repository item linked to the action, i.e. the UI element on which the validation is performed.
If written as a statement, the validation would read as follows:
Screenshot1 is contained (
ContainsImage) in the UI-element referenced by the repository item
TheCat, THEN the validation returns the value ‘