Welcome to the Ranorex Support Portal

Complex customizations

In this chapter, you’ll find instructions on how to perform a range of more complex report customizations. Since they require coding skills, you should be familiar with code modules in Ranorex Studio.


Further reading

If you are not familiar with the concept of code modules and their application, refer to Ranorex Studio expert > ⇢ Code modules.

In this chapter

Download the sample solution

The examples in this chapter are based on a sample solution that you can download from the link below.


Sample solution

Theme: Complex report customizations
Time: 30 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 Studio versions 8.0 or higher. You must agree to the automatic solution upgrade for versions 8.2 and higher.

The standard report classes

The easiest way to create a report message in code is using one of the six different standard report classes.

Standard report classes

Ranorex Studio has six standard report classes, as shown below. These classes correspond to the standard report levels.

Ranorex.Report.Debug(“Debug message”);

Ranorex.Report.Info(“Information message”);

Ranorex.Report.Warn(“Warning message”);

Ranorex.Report.Error(“Error message”);

Ranorex.Report.Success(“Success message”);

Ranorex.Report.Failure(“Failure message”);

  1. Create a code module and open it.

  2. Add the class instantiations for the standard report classes in the Run() method.

  1. Run the code module from the test suite to see the results in the report.

Report messages from standard report classes
Note Icon


Make sure the report level of the test suite is set to Debug to display all report messages.

Report with user code actions

In addition to using code modules, you can also create report messages in recording modules with user code actions.


Further reading

To learn more about user code actions, refer to:
Ranorex Studio fundamentals > Actions > ⇢ User code actions.

  1. Open a recording module.

  2. Insert a new user code action called ReportInformation() and open it.

  1. Add a new report information message to the constructor of the user code action.

  2. Run the recording module to see the report message in the test report.

Customize the default report category

By default, the category of custom report messages is User. You can change this to a different value, either on a per-message basis or for all messages until you change it back.

Per message

  1. Create a new code module and open it.

  2. Add the code shown below.

Defining a temporary custom report category
  1. This report message appears under the category Cat.A.

  2. This report message appears under the default category User.


  1. The report messages with their categories as defined above.

Change default category

  1. Create a new code module and open it.

  2. Add the code shown below.

Defining a permanent custom report category
  1. This line defines Cat.A as the new value for the default category for user-defined report messages.

  2. These report messages appear under the new default category.


  1. User-defined messages appear under the category Cat.A until you change it.

Define custom report levels

You can define report levels with a custom name and value.

  1. Define the custom report levels MID and LOW using the code below.

  2. Create two user-defined report messages with the new report levels.


  1. The report messages appear with the new report levels.

Format custom report levels

  1. Add the code below to apply custom CSS formatting to a report level.

  1. See the formatted result in the test report

Set threshold report level with custom report levels

In this example, you’ll set the threshold report level for messages using a custom report level.

  1. Define two custom report levels.

  2. Set the current threshold report level to MID and higher.

  3. Create two report messages, one with LOW and one with MID as report levels.


  1. Only report messages with the report level MID and higher appear in the report.

Override current report level

You can override the current report level with the special report level Always.

Overriding the current report level
  1. Define two custom report levels.

  2. Set the current threshold report level to MID and higher.

  3. Create two report messages, one overriding the current report level.


  1. The second message appears regardless of the current report level.

Report screenshots

  1. Add the code below to send a screenshot to the report. If you don’t specify a repository item, Ranorex Studio takes a screenshot of what’s visible at the time of code execution.

  1. The desktop screenshot in the test report.


Further reading

To learn how to take screenshots of specific repository items, refer to Ranorex Studio expert > ⇢ Code modules.

Report a system summary

  1. Add the code below to display a system summary in the report.

  1. The system summary appears as an Info message in the report.

Add customized data

You can collect customized data during a test run and write it to the raw data file (.rxlog.data) that’s used to generate the final report.

Add custom data to raw data file

Customized data collection is triggered by a user code action with a method that tracks customized data.

  1. Define an object that references the current activity stack of Ranorex Studio.
    The activity stack is where all activities during a test run are collected by means of a stack data structure.

  2. Add an activity to the activity stack.
    The activity stack method CustomProperties adds a reported activity to the activity stack. It is defined by two strings, name (e.g. myName) and value (e.g. myValue).


  • The result is a custom data field pair in the corresponding data file
  1. The raw data file contains the custom data.

  • If you want to apply the test data outside of Ranorex Studio report generation, you can parse the XML file as needed.
  • To include the custom data in a Ranorex Studio report, please refer to the next section.

Include custom data in report


Further reading

If you are not familiar with XML and the corresponding concepts of CSS and XSL specifications, we recommend the website of the World Wide Web Consortium (W3C) for more information.

To include custom data in Ranorex Studio reports, you must modify the corresponding XSL specification file of the report. You can do this in any XML editor or in Ranorex Studio.

  1. Add the code in the picture below to the file.

  1. This line identifies the field pair where the custom data is located in the raw data file.

  2. This optional line adds a header that will be displayed before the custom data.

  3. This line gets the field value of the corresponding field name.


  1. The report contains the custom data.



Get the latest test automation information right in your mailbox.


© 2024 Ranorex GmbH. All Rights Reserved