Introduction | Ranorex
HomeUser GuideRanorex Studio AdvancedIntroduction

Image-based automation

Automated software testing usually is based upon the recognition of user-interface elements (UI-elements). Many of them may be identified based on text. Alternatively, the recognition of pixel images instead of text is necessary for test automation. Here – image-based automation is a well-proven method to identify, detect and apply UI-elements. Everything needed to make use of this method is introduced and explained herein.

In this chapter

    Sample solution

    The herein introduced concepts are put into a sample solution which can be downloaded. You are invited to experiment with the sample solution and improve your knowledge.

    Training! What do I do?

    Theme: Image-based automation
    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 ImagebasedAutomation.rxsln

    Turning image-based automation on/off

    Image-based automation is turned on and off in the Recorder control center any time during recording.

    Turning image-based automation on/off

    Turning image-based automation on/off

    Image-based checkbox in Ranorex Recorder (not checked, i.e. turned off)
    Image-based automation turned on
    Activation of image-based automation through Recorder hotkeys

    Activation of image-based automation through Recorder hotkeys

    Press I in activated Recorder hotkeys
    Image-based automation turned on

    Why image-based automation?

    The reasons for using image-based automation within automated testing of GUI software might not be obvious. This section is to show you at least one reason where text-based automation fails, and image-based automation is the solution.

    Example preparation

    Watch out the demonstration example for image-based automation with the Ranorex demo application. We use the instant recording functionality of the Ranorex Recorder during this example.

    Example for image-based automation

    Example for image-based automation

    Start the demo application and select Image-based automation as working environment
    Choose Instant recording during technology selection of the Ranorex Studio Recorder

    Text-based recording

    Track & record three (3) consecutive dates in the calendar view of the demo application in the default text-based automation mode and see the result.

    Tracking & recording calendar dates in text-based automation

    Tracking & recording calendar dates in text-based automation

    Verify that default text-based automation is turned on (i.e. image-based automation is not selected)
    Recording (clicking) the three dates ’24’, ’25’ & ’26’ of the calendar leads to …
    … an action table with three corresponding action items representing the calendar mouse clicks

    Test recording result

    See the result of the default test recording when the test run is started. The recorded calendar dates are identified correctly and will be selected correspondingly during the test run. A successful test report shows the result of the three action items displayed.

    Successful test run of calendar dates recording

    Successful test run of calendar dates recording

    Change of test conditions

    Assume that the test conditions change – and – that the calendar view changes to a different month due to time progress between recording and replaying the test.

    Change in test conditions

    Change in test conditions

    The calendar view changes from January 2018 to February 2018 with an obviously different calendar view. The recorded dates ’24’, ’25’ & ’26’ are now at a different position within the calendar.

    Watch the result of the test run with the previous recorded calendar dates:

    Test result with changed test conditions

    Test result with changed test conditions

    Result interpretation

    • The test runs without failure and reports a success (see test report)
    • But – the result is wrong, as dates at the originally tracked positions in the calendar are identified during the test run, and not, the correct dates at their changed position!
    tipp icon

    Attention

    Sometimes, Ranorex is not able to identify a UI-element for an individual click point (as of dates within a calendar). Then, text-based automation stores absolute and relative positions rather than graphical UI-elements which leads to the herein described problem.

    Conclusion

    In the next chapter, we show you how image-based automation overcomes this challenge.