Ranorex Help Center How can we help you?

Lesson 2 - Ranorex Modules and Test Actions

This lesson will show you the benefits of splitting your recordings into smaller pieces (to provide for reusability) and how your projects can be easily assembled afterwards using drag and drop functionality in Ranorex Studio.

Refactoring: Why you should Separate Recordings

The ease of recording user actions encourages one to record all test cases without thinking about reusability. But in the long run, this could increase the effort in test automation maintenance. For this reason you should separate a recording into smaller reusable recording modules as suggested by the keyword driven methodology. In the following section you will learn how to separate existing recordings into smaller pieces to be reused by other test cases.


Screencast The screencast "Ranorex Modules – Test Automation Actions" provides a short introduction to preparing recorded actions for reusability by extracting reusable Ranorex Modules. This screencast can be found at http://youtube.com/watch?v=GrrKnf8cQ2g

Identifying Modules

In your first recording, you did the following from a keyword driven perspective:
  • Started the application KeePass
  • Logged in
  • Added a new entry
    • Set the attributes for title, username, password, URL
    • Chose an icon
    • Set the expiration value
  • Validated the existence of the newly created entry in the grid
  • Deleted the entry
  • Saved the changes
  • Closed the application

In order to split recordings into smaller automation modules, select related actions and use the context menu item 'Move to new Recording Module'. Within the underlying recording, the three actions performing the log-in should be selected and moved into a new recording named 'LogIn'. These three actions are a click on the password field, a key sequence on the password field and finally a mouse click on the OK button.

Move login actions to a new recording

Move login actions to a new recording

Create a new recording named 'LogIn'

Create a new recording named 'LogIn'

Then, select and move all items used to add a new entry to the database to a new recording named 'AddEntry.rxrec'.

Repeat the previous steps to create modules for 'ValidateEntry', 'DeleteEntry', 'SaveDB' and for 'CloseSUT'.

Also rename the initial recording file (with only one recorded item left for starting the application) from 'Recording1.rxrec' to 'StartSUT.rxrec'. In the end you should have seven separate new recording modules.

After splitting the initial recording into smaller test actions, the Ranorex Module Browser also contains the new modules. Now simply use the drag and drop feature to combine these modules within the test case.


Use the drag and drop feature to specify your test case within the test suite view

Use the drag and drop feature to specify your test case within the test suite view

When having a huge amount of different modules you can use the search functionality of the Ranorex Module Browser which searches through the module name as well as the modules XmlDoc Summary. The XmlDoc Summary can be set in the properties of the module. You can open the properties by right-clicking a module in the Ranorex Module Browser and choosing 'Properties' in the context menu.

Note When you are going to use the XmlDoc Summary, be sure to enable XML documentation creation in your project settings. In Ranorex Studio this setting can be found in the 'Compiling' tab in the project properties.

Set a modules XmlDoc Summary

Set a modules XmlDoc Summary

Separating a recording into smaller modules is the first step in building robust and reusable automation modules. In addition replace constant values used within these modules with variables in order to enable parameterization. Read more about how to use variables in Lesson 3: Data-Driven Testing.