Use the Ranorex Studio Demo Application for this example and record the actions in the Recorder.
You can download the completed solution with all the above steps carried out below.
Theme: Image-based testing
Time: < 30 minutes
Install the sample solution
- Unzip to any folder on your computer.
-
Start Ranorex Studio and open the solution file
ImagebasedAutomation.rxsln
Example
- 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.
Object-oriented recording
- Ensure image-based recording is disabled.
- Click the three dates 24, 25, and 26 in the calendar and stop the recording.
- Confirm the action table shows the three click actions.
Run the test
Run the test once and verify:
- The recorded calendar dates are identified correctly.
- Each click action in the report corresponds to the correct date in the calendar.
Change of test conditions
So far, the object-oriented approach has worked flawlessly. 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 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.
- However, this is a false positive. The test identifies the wrong dates (21, 22, and 23 in our case, instead of 24, 25, and 26).
Hint: Sometimes Ranorex Studio can’t identify an individual UI element (e.g., dates within certain calendar views). Instead, it then uses absolute and relative positions rather than the actual object, which leads to the above issue. test the following:
Advanced image-based automation
As you read on the previous page, image-based testing is sometimes the solution to an issue. However, as with any other testing approach, you need to apply it correctly, or it will fail.
Proper image-based testing can get challenging when the recorded and the actual image during test execution don’t match. This can be caused by simple things like a UI element being highlighted or icons changing during test execution. False positives can also be an issue when, instead of the intended UI element, a similar-looking one is identified.