Welcome to the Ranorex Support Portal


In most cases, you can automate tests with Ranorex Studio and never touch a single line of code. But if you prefer to write your own code to automate a test, you can do so in Ranorex Studio with code modules.

In the following chapters, you’ll learn how to create code modules and how to tackle typical testing tasks with them, like accessing repository items, working with variables, and data-driven testing.

You can either follow along with the instructions in these chapters and build your code modules step by step based on the sample solution below, or you can download our completed sample solution in the chapter ⇢ Module variables and data-driven testing and experiment with the completed code modules.

In this chapter


Watch our on-demand webinar

Mastering User Code in Ranorex Studio: Extend your automated tests with user code actions, user code modules, and user code libraries

Download the sample solution

The examples in this chapter are based on the sample solution for the chapter Data-driven testing. Download the sample solution here to follow along with the instructions in the following chapters.


Sample solution

Theme: Code modules
Time: 45 minutes

Install the sample solution:

  1. Unzip to any folder on your computer.

  2. Start Ranorex Studio and open the solution file RxDatabase.rxsln

Note Icon


The sample solution is available for Ranorex versions 8.0 or higher. You must agree to the automatic solution upgrade for versions 8.2 and higher.


To keep everything organized, we’ll put all of our code modules in their own folder, called Code modules. It’s already there in the sample solution. If you’re using your own solution, simply create a code module as described below.

Create a code module

To create a new code module:

  1. In the test suite view, click the test container where you want to add the code module.


Click either


The Add code module symbol in the Ranorex Studio toolbar.


Add > New code module in the test suite menu or the context menu of the test container.

  1. Select the Code modules folder that comes with the sample solution, or if working in your own solution, select the folder that you created in the preparation step above. Click OK.

  2. Name the new code module and click Create.

Ranorex Studio creates the code module in the programming language that’s been configured for the solution/the project. The standard language is C#, and the following explanations are based on C#.

Code modules are organized into several sections

  1. Integration of the required classes and definition of the namespace

  2. Class definition, including the necessary empty constructor.

  3. Run() method, where you can implement your code. This is also where default values for various timeouts are predefined.



Get the latest test automation information right in your mailbox.


© 2024 Ranorex GmbH. All Rights Reserved