Table of Contents

Class Report

Namespace
Ranorex
Assembly
Ranorex.Core.dll

The Ranorex reporting service.
Used to log messages to a number of configured loggers.

public class Report
Inheritance
Report
Inherited Members

Properties

CustomCategoryStyles

Allows setting of custom formatting CSS styles per category. These styles override ReportLevel styles if set.

public static Dictionary<string, string> CustomCategoryStyles { get; }

Property Value

Dictionary<string, string>

DefaultCategory

Gets or sets the default report category to use if not explicitly specified when reporting messages.

public static string DefaultCategory { get; set; }

Property Value

string

The default category name.

MinimumReportLevel

Gets or sets the current report level that is the minimum ReportLevel message need to have to be included in the report.

public static ReportLevel MinimumReportLevel { get; set; }

Property Value

ReportLevel

The minimum report level that log entries need to have to be included in the report.

Remarks

The default level is Info.

Methods

AttachLogger(IReportLogger)

Attaches a custom logger to the reporting environment.

public static void AttachLogger(IReportLogger logger)

Parameters

logger IReportLogger

The logger.

Copy(ReportEnvironment, string)

Copies a XML or zipped XML report file and all the external files referenced by the report file to a file. This method automatically handles copying from and to zipped and unzipped report files.

public static void Copy(ReportEnvironment reportEnvironment, string destinationReportFileName)

Parameters

reportEnvironment ReportEnvironment

Current report environment.

destinationReportFileName string

Full path to copy the report file to.

Remarks

Make sure the report is saved first to copy all files. Only currently existing files are copied.

Copy(string, string)

Copies a XML or zipped XML report file and all the external files referenced by the report file to a file. This method automatically handles copying from and to zipped and unzipped report files.

public static void Copy(string sourceLog, string destinationReportFileName)

Parameters

sourceLog string

Full path to the source report file.

destinationReportFileName string

Full path to copy the report file to.

Remarks

Make sure the report is saved first to copy all files. Only currently existing files are copied.

Debug(string)

Logs a debug-level message, using the default category.

public static void Debug(string message)

Parameters

message string

The message text.

Debug(string, string)

Logs a debug-level message.

public static void Debug(string category, string message)

Parameters

category string

The category name.

message string

The message text.

DetachLogger(IReportLogger)

Detaches a custom logger from the reporting environment.

public static void DetachLogger(IReportLogger logger)

Parameters

logger IReportLogger

The logger.

End()

Ends reporting. It is not required to explicitly call this method before shutdown.

public static void End()

Error(string)

Logs an error-level message, using the default category.

public static void Error(string message)

Parameters

message string

The message text.

Error(string, string)

Logs an error-level message.

public static void Error(string category, string message)

Parameters

category string

The category name.

message string

The message text.

Failure(string)

Logs a logical failure (e.g. test step failure) message, using the default category.

public static void Failure(string message)

Parameters

message string

The message text.

Remarks

Calling this method marks the current test container as failed, but does not stop execution of the current module or test container. If you want the execution of the current module to stop immediately, call Fail(string) instead.

Failure(string, string)

Logs a logical failure (e.g. test step failure) message.

public static void Failure(string category, string message)

Parameters

category string

The category name.

message string

The message text.

Remarks

Calling this method marks the current test container as failed, but does not stop execution of the current module or test container. If you want the execution of the current module to stop immediately, call Fail(string) instead.

~Report()

Finalizer for automatic logger shutdown.

protected ~Report()

HasReportDataFileExtension(string)

Determines if a file name has the Ranorex Stub View report file extension.

public static bool HasReportDataFileExtension(string reportFileName)

Parameters

reportFileName string

The file name to check.

Returns

bool

True if the file has the ".rxlog.data" extension.

HasReportFileExtension(string)

Determines if a file name has the Ranorex Xml report file extension.

public static bool HasReportFileExtension(string reportFileName)

Parameters

reportFileName string

The file name to check.

Returns

bool

True if the file has the ".rxlog" extension.

HasZipReportFileExtension(string)

Determines if a file name has the Ranorex Zip report file extension.

public static bool HasZipReportFileExtension(string reportFileName)

Parameters

reportFileName string

The file name to check.

Returns

bool

True if the file has the ".rxzlog" extension.

Info(string)

Logs an info-level message, using the default category.

public static void Info(string message)

Parameters

message string

The message text.

Info(string, string)

Logs an info-level message.

public static void Info(string category, string message)

Parameters

category string

The category name.

message string

The message text.

IsReportFile(string)

Determines if a file is a valid Ranorex report file.

public static bool IsReportFile(string reportFileName)

Parameters

reportFileName string

The file name to check.

Returns

bool

True if the file is a valid Ranorex report file.

IsReportFile(string, string)

Determines if a file is a valid Ranorex report file.

public static bool IsReportFile(string reportFileName, string fileFilter)

Parameters

reportFileName string

The file name to check.

fileFilter string

A list of known file extensions that are not report files.

Returns

bool

True if the file is a valid Ranorex report file.

Adds the specified link to the report. If the link is a relative file path or points to a file within the report directory, the linked file will also be included in zipped or copied versions of the report.

public static void Link(ReportLevel level, string category, string message, string link, params IReportMetadata[] metaData)

Parameters

level ReportLevel

The reporting level of the message.

category string

The category name.

message string

An optional message to log to the report.

link string

The link to add to the report.

metaData IReportMetadata[]

Advanced reference information for use in the report. Used by Ranorex internally.

Exceptions

ArgumentNullException

If category or link are null.

Adds the specified link to the report. If the link is a relative file path or points to a file within the report directory, the linked file will also be included in zipped or copied versions of the report.

public static void Link(string link)

Parameters

link string

The link to add to the report.

Exceptions

ArgumentNullException

If link is null.

Adds the specified link to the report. If the link is a relative file path or points to a file within the report directory, the linked file will also be included in zipped or copied versions of the report.

public static void Link(string message, string link)

Parameters

message string

An optional message to log to the report.

link string

The link to add to the report.

Exceptions

ArgumentNullException

If link is null.

Log(ReportLevel, string)

Logs a message using the DefaultCategory.

public static void Log(ReportLevel level, string message)

Parameters

level ReportLevel

The reporting level of the message.

message string

The message text itself.

Log(ReportLevel, string, string)

Logs a message.

public static void Log(ReportLevel level, string category, string message)

Parameters

level ReportLevel

The reporting level of the message.

category string

The category name.

message string

The message text itself.

Log(ReportLevel, string, string, params IReportMetadata[])

Logs a message.

public static void Log(ReportLevel level, string category, string message, params IReportMetadata[] metaData)

Parameters

level ReportLevel

The reporting level of the message.

category string

The category name.

message string

The message text itself.

metaData IReportMetadata[]

Advanced reference information for use in the report. Used by Ranorex internally.

LogData(ReportLevel, string, object)

Logs a data message.

public static void LogData(ReportLevel level, string category, object data)

Parameters

level ReportLevel

The reporting level of the message.

category string

The category name.

data object

The data object to log.

Remarks

Note that this is not support by all loggers, nor are all data types supported.

LogData(ReportLevel, string, string, object)

Logs a data message.

public static void LogData(ReportLevel level, string category, string message, object data)

Parameters

level ReportLevel

The reporting level of the message.

category string

The category name.

message string

An optional message for the data.

data object

The data object to log.

Remarks

Note that this is not support by all loggers, nor are all data types supported.

LogData(ReportLevel, string, string, object, params IReportMetadata[])

Logs a data message.

public static void LogData(ReportLevel level, string category, string message, object data, params IReportMetadata[] metaData)

Parameters

level ReportLevel

The reporting level of the message.

category string

The category name.

message string

An optional message for the data.

data object

The data object to log.

metaData IReportMetadata[]

Advanced reference information for use in the report. Used by Ranorex internally.

Remarks

Note that this is not support by all loggers, nor are all data types supported.

LogHtml(ReportLevel, string)

Logs a message using the DefaultCategory. The message can contain XHTML markup.

public static void LogHtml(ReportLevel level, string messageHtml)

Parameters

level ReportLevel

The reporting level of the message.

messageHtml string

The message text itself.

LogHtml(ReportLevel, string, string)

Logs a message. The message must contain valid XHTML markup.

public static void LogHtml(ReportLevel level, string category, string messageHtml)

Parameters

level ReportLevel

The reporting level of the message.

category string

The category name.

messageHtml string

The message text itself.

LogHtml(ReportLevel, string, string, params IReportMetadata[])

Logs a message. The message must contain valid XHTML markup.

public static void LogHtml(ReportLevel level, string category, string messageHtml, params IReportMetadata[] metaData)

Parameters

level ReportLevel

The reporting level of the message.

category string

The category name.

messageHtml string

The message text itself.

metaData IReportMetadata[]

Advanced reference information for use in the report. Used by Ranorex internally.

ProcessSummary(Element)

Logs a message containing a short process summary.

public static void ProcessSummary(Element element)

Parameters

element Element

An element which belongs to the process to gather information from.

Remarks

The process summary contains information about the process resource usage.

ProcessSummary(RepoItemInfo)

Logs a message containing a short process summary.

public static void ProcessSummary(RepoItemInfo repoItemInfo)

Parameters

repoItemInfo RepoItemInfo

An repository item representing an element which belongs to the process to gather information from.

Remarks

The process summary contains information about the process resource usage.

ProcessSummary(Process)

Logs a message containing a short process summary.

public static void ProcessSummary(Process p)

Parameters

p Process

The process to gather information from.

Remarks

The process summary contains information about the process resource usage.

ProcessSummary(int)

Logs a message containing a short process summary.

public static void ProcessSummary(int pid)

Parameters

pid int

The process id of the process to gather information from.

Remarks

The process summary contains information about the process resource usage.

ProcessSummary(string)

Logs a message containing a short process summary.

public static void ProcessSummary(string imageName)

Parameters

imageName string

The name of the process image/executable to gather information from.

Remarks

The process summary contains information about the process resource usage.

Screenshot()

Logs a message containing a screenshot of the whole desktop.

public static void Screenshot()

Remarks

This is not supported by the console logger.

Screenshot(Element)

Logs a message containing a screenshot of a specified element.

public static void Screenshot(Element target)

Parameters

target Element

The element to make the screenshot from.

Remarks

Screenshots will not show up in the console logger.

Screenshot(Element, bool)

Logs a message containing a screenshot of a specified element.

public static void Screenshot(Element target, bool highlightWithinSurroundingArea)

Parameters

target Element

The element to make the screenshot from.

highlightWithinSurroundingArea bool

If set to true the screenshot will not only contain the element, but also its surrounding area and will highlight the element within it.

Remarks

Screenshots will not show up in the console logger.

Screenshot(ReportLevel, string, string, Element, bool, params IReportMetadata[])

Logs a message containing a screenshot of a specified element.

public static void Screenshot(ReportLevel level, string category, string message, Element target, bool highlightWithinSurroundingArea, params IReportMetadata[] metaData)

Parameters

level ReportLevel

The reporting level of the message.

category string

The category name.

message string

An optional message for the screenshot.

target Element

The element to make the screenshot from.

highlightWithinSurroundingArea bool

If set to true the screenshot will not only contain the element, but also its surrounding area and will highlight the element within it.

metaData IReportMetadata[]

Advanced reference information for use in the report. Used by Ranorex internally.

Remarks

Screenshots will not show up in the console logger.

Screenshot(string, Element)

Logs a message containing a screenshot of a specified element.

public static void Screenshot(string message, Element target)

Parameters

message string

An optional message for the screenshot.

target Element

The element to make the screenshot from.

Remarks

Screenshots will not show up in the console logger.

Screenshot(string, Element, bool)

Logs a message containing a screenshot of a specified element.

public static void Screenshot(string message, Element target, bool highlightWithinSurroundingArea)

Parameters

message string

An optional message for the screenshot.

target Element

The element to make the screenshot from.

highlightWithinSurroundingArea bool

If set to true the screenshot will not only contain the element, but also its surrounding area and will highlight the element within it.

Remarks

Screenshots will not show up in the console logger.

Setup(ReportLevel, string, bool)

Sets up the reporting environment compatible with Ranorex version 2.X.

public static void Setup(ReportLevel minLevel, string xmlReportFileName, bool logToConsole)

Parameters

minLevel ReportLevel

The minimum ReportLevel for messages that are to be written to the report.

xmlReportFileName string

Name of the XML report file, or null if XML logging should be disabled.

logToConsole bool

if set to true, logging to console is enabled.

Setup(ReportLevel, string, bool, bool)

Sets up the reporting environment compatible with Ranorex version 2.X.

public static void Setup(ReportLevel minLevel, string xmlReportFileName, bool logToConsole, bool appendExisting)

Parameters

minLevel ReportLevel

The minimum ReportLevel for messages that are to be written to the report.

xmlReportFileName string

Name of the XML report file, or null if XML logging should be disabled.

logToConsole bool

if set to true, logging to console is enabled.

appendExisting bool

if set to true, append to existing XML file instead of overwriting it.

SetupDefault()

Sets up the reporting environment with Info, XML logging and console logging enabled.

public static void SetupDefault()

Snapshot(Element)

Creates and stores a snapshot of the specified target element and adds a link to the snapshot to the report.

public static void Snapshot(Element target)

Parameters

target Element

The target element to create the snapshot of.

Exceptions

ArgumentNullException

If target is null.

Snapshot(ReportLevel, string, string, Element, params IReportMetadata[])

Creates and stores a snapshot of the specified target element and adds a link to the snapshot to the report.

public static void Snapshot(ReportLevel level, string category, string message, Element target, params IReportMetadata[] metaData)

Parameters

level ReportLevel

The reporting level of the message.

category string

The category name.

message string

An optional message to log to the report.

target Element

The target element to create the snapshot of.

metaData IReportMetadata[]

Advanced reference information for use in the report. Used by Ranorex internally.

Exceptions

ArgumentNullException

If target is null.

Snapshot(string, Element)

Creates and stores a snapshot of the specified target element and adds a link to the snapshot to the report.

public static void Snapshot(string message, Element target)

Parameters

message string

An optional message to log to the report.

target Element

The target element to create the snapshot of.

Exceptions

ArgumentNullException

If target is null.

Start()

Starts reporting with the previously configured settings.

public static void Start()

Remarks

To restart reporting, End() needs to be called first.

Success(string)

Logs a logical success (e.g. test step success) message, using the default category.

public static void Success(string message)

Parameters

message string

The message text.

Success(string, string)

Logs a logical success (e.g. test step success) message.

public static void Success(string category, string message)

Parameters

category string

The category name.

message string

The message text.

SystemSummary()

Logs a message containing a short system the summary.

public static void SystemSummary()

Remarks

The system summary contains information about the host, OS, locale, memory and screens.

Unzip(string, string)

Unzips a zipped XML report file (with the extension ".rxzlog") and all the external files references.

public static string Unzip(string zipReportFileName, string targetDirectory)

Parameters

zipReportFileName string

Full file path of the zipped ".rxzlog" file.

targetDirectory string

The directory to save extracted XML report file in.

Returns

string

The full file path of the extracted XML report file.

Warn(string)

Logs a warning-level message, using the default category.

public static void Warn(string message)

Parameters

message string

The message text.

Warn(string, string)

Logs a warning-level message.

public static void Warn(string category, string message)

Parameters

category string

The category name.

message string

The message text.

Zip(ReportEnvironment, string, string)

Zips the XML report file and all the external files referenced by the report file to a zip file with the extension ".rxzlog".

public static void Zip(ReportEnvironment reportEnvironment, string targetDirectory, string zipReportFileName)

Parameters

reportEnvironment ReportEnvironment

Active report environment.

targetDirectory string

Directory to save zipped XML report file in. If null or empty, CurrentDirectory is used.

zipReportFileName string

Name of the zipped report file. The ".rxzlog" extension is added by default.

Zip(string, string, string)

Zips the XML report file and all the external files referenced by the report file to a zip file with the extension ".rxzlog".

public static void Zip(string sourceLog, string targetDirectory, string zipReportFileName)

Parameters

sourceLog string

Full path to the source report file.

targetDirectory string

Directory to save zipped XML report file in. If null or empty, CurrentDirectory is used.

zipReportFileName string

Name of the zipped report file. The ".rxzlog" extension is added by default.