Ranorex Help Center

How can we help you?

Adding Repository Items

Screencast In addition to going through the explanations on the following pages, you can get a good overview of "Adding Repository Items" by watching our screencasts on this topic. How to add items manually is explained here: http://youtu.be/C1AVdFbUlIo. Several ways to use the Ranorex Spy tool are pointed out in this video: http://youtu.be/p25kFcjcuBs.


In this section you will find several ways to add items to your repository without using the recording functionality. In addition, you'll learn about how you can manually add actions (clicking, typing, etc.) to the recorder and connect these actions to repository items to specify the UI element the action should be executed on. As an example, a new recording module 'FindEntry' will be created which opens the KeePass search form and searches for the 'WordPressDemo' from Lesson 3: Data-Driven Testing.

You can also add new items to your repository using the Ranorex Spy tool. The following section describes how to add the 'Find' button which was not clicked during the recording session in order to automate a click on the button later on.

First click the 'View Spy' button within the Ranorex Studio toolbar to open Ranorex Spy.


Open Ranorex Spy to track and add items to the repository

Open Ranorex Spy to track and add items to the repository

Next track the 'Find' button in KeePass using the 'Track' button in Ranorex Spy. Successful identification is indicated by a highlight frame around the button.
Track and identify the 'Find' button with Ranorex Spy

Track and identify the 'Find' button with Ranorex Spy



As a third step, add the button to the repository as shown in following figure.
Add the item to the currently open repository

Add the item to the currently open repository

Note Alternatively you can drag and drop the item from Ranorex Spy directly into the repository from Ranorex Studio.

Newly created item in the repository

Newly created item in the repository

Note It is also possible to track UI elements directly from the repository using the Track button.

Tracking directly from the repository

Tracking directly from the repository

Now the 'Find' button is part of the repository and is ready to be used by code or recording modules. Create a new recording module in order to handle the 'Search' scenario. Use the 'Add New Action' drop-down button in the toolbar of the Ranorex Recorder and add a new 'Mouse' action. There is more than one way to connect the repository item to this action:

  • Drag and drop the item from the repository directly into the recording grid or
  • Click on the 'browse repository button' in the recording grid (column for repository item)

Connect repository item to action using the browse repository button

Connect repository item to action using the browse repository button

Alternatively you can also drag and drop a repository item into the recording grid and create a new action this way (you will be asked which type of action you want to create when dropping the item into the grid).


Context menu for choosing action type when creating a new recording action directly using drag and drop

Context menu for choosing action type when creating a new recording action directly using drag and drop

A new recording module was already created containing a single action for clicking on the 'Find' button in KeePass. This recording module should be able to simulate entering text into the search form and clicking on the 'OK' button to start the search. We still need more elements in our repository and some more actions in our recording table. Please carry out the following steps, which are quite similar to the steps already done in this section.

  • Open the Ranorex Spy tool (if not already opened)
  • Track the 'Find What' text field in KeePass using the 'Track' button in Ranorex Spy
  • Add the tracked text field to the repository (either with the context menu or with drag and drop)
  • Rename this repository item to something meaningful (e.g. FindText)
  • Add a new action ('Mouse') to the recording in Ranorex Studio
  • Connect this action to the repository item 'FindText'
  • Add a new action (Key Sequence) to the recording
  • Change the value in the column 'Sequence' to a text phrase that you want to search for (e.g. WordPressDemo)
  • Connect this action to the repository item 'FindText'
  • Open the Ranorex Spy tool (if not already opened)
  • Track the 'Find' button from KeePass Search form using the 'Track' button in Ranorex Spy
  • Add the tracked button to the repository (choosing one of the already mentioned methods)
  • Add a new action (Mouse) to the recording in Ranorex Studio
  • Connect this action to the repository item 'Button Find'


Note This long list of steps shows the manual method of creating a recording. Of course these steps could be also done as a normal recording without worrying about assigning repository items.


You can easily execute a single action and multiple actions within the recorder by using the context menu item 'Play Selected Item/s', 'Play To Here' or 'Play From Here'.


Execute a single action to simulate a key sequence on the edit field 'FindText'

Execute a single action to simulate a key sequence on the edit field 'FindText'

Now your manually created recording consists of four actions including opening the form, clicking on the text field, entering a key sequence and finally clicking on the 'Find' button. This simple recording can now easily be embedded in your test case and can be made use of in any (suitable) position.


Note It is also possible to add a recording module two or more times to a test case. See the following example for more details.

A More Advanced Test Case Example

Within this test case it may be a good idea to combine the 'FindEntry' module with the 'Validate' module. The test case structure in the following figure would extend the current example with a more complex combination of modules:
Example of an advanced test case using different code modules multiple times

Example of an advanced test case using different code modules multiple times

To explain the test case it should be mentioned that after the setup region ('StartAndLogin') this test case tries to 'find' a value (WordPressDemo) and to 'validate' the results. If KeePass is started with an empty database, this validation will intentionally fail. After adding the entry ('AddEntry') the second instance of the 'Find' module with the subsequent 'ValidateEntry' module would succeed if the previous adding action succeeded. The ongoing test case continues with the deletion of the item and tries to 'find' and to 'validate' again, which now intentionally fails again. The final teardown region containing the 'SaveAndClose' module group is executed anyway.

Note To prevent the recorder from stopping the run on failing the validation (intentional) please have a look at Lesson 5: Ranorex Recorder - Continue On Fail and Disable and enable continuing on fail.

Repository Items Representing Multiple Elements

You can create a repository item using a RanoreXPath which delivers multiple UI elements. This might be very helpful, for example, if you want to validate the visibility of any element among a great number of checkboxes on a configuration form. This is mainly used by code modules if you do not want to have a list of hundreds of repository items representing a single checkbox each.


RanoreXPath delivering multiple results (All buttons from the toolbar in KeePass)

RanoreXPath delivering multiple results (All buttons from the toolbar in KeePass)

Screencast This scenario is presented in the screencast "Code Modules - Benefits and Use Cases". Please follow the link to watch it now: http://youtu.be/4k-lcNxQd2U#t=3m28s – it will open at the position in which this topic is covered.


Use the Ranorex Spy to prepare a RanoreXPath with multiple result elements and add it to the repository as described in the previous section.
Repository items delivering a list of elements can be used in code modules as described in Code Examples