Lesson 2: Ranorex Modules - 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.

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 'New Recording From Selection'. 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 first action to a new recording
Move first action 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 'CloseApplication'.

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.

Recording module 'StartSystemUnderTest'
Use the drag and drop feature to specify your test case within the test suite view
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.