Image-based testing basics
On the previous page, we showed you a case where object-oriented testing fails to identify the correct UI elements. On this page, we’ll show you the basics of image-based testing to solve this issue.
In this chapter
The image-based approach
As on the previous page, we want to test the following:
In the calendar view of the Ranorex Studio Demo Application, we want to perform mouse clicks on three different dates (24, 25, and 26) of a month. After changing the month, the mouse clicks should still be performed on the same dates.
Start the demo application and click the Image-based automation tab.
In Ranorex Studio, create a new desktop solution with the solution wizard and open Recording1 in this solution.
In the recording module view of Recording1, click RECORD.
Image-based recording
We’ll now record mouse clicks on three consecutive dates in the calendar view of the demo application using the image-based approach.
Ensure image-based recording is enabled.
Click the three dates 24, 25, and 26 in the calendar and stop the recording.
The action table displays the three corresponding actions.
Note
When image-based recording is enabled, Ranorex Recorder frames UI elements in green instead of purple (object-oriented recording), as shown in the image below.
Object-oriented recording with purple frame
Image-based recording with green frame
Run the test
When you run the test, you’ll see that
- the recorded calendar dates are identified correctly.
- each click action in the report corresponds to the correct date in the calendar.
In other words, at this point the test results are the same as with object-oriented testing.
Change of test conditions
Now assume that you run the test a couple of months from its creation. This means that the calendar view will have changed to a different month. Let’s see how our image-based test performs in this case.
In the calendar in the demo application, switch to any month where the recorded dates 24, 25, and 26 are at a different position in the calendar.
Run the test again and see what happens.
- The test runs without failure and reports a success.
- Ranorex Studio has identified the correct dates despite their changed positions.
- Image-based testing has solved the issue created by object-oriented testing.