Sahi Pro - Sahi Reports

abstract This section explains how reporting works in Sahi and how to customize it.

Reports - Architecture and Flow

When a script is run, steps executed on the browser are automatically logged by Sahi.
  1. All report data is stored in the database by default.
  2. At the end of a suite, Sahi Pro reads the data from the database and converts them to XML
  3. The XML is then converted into desired reports using XSL transformations
    info By default, Sahi Pro ships with XSLs for html, xml, junit, excel and email formats.
    These are stored in sahi_pro/userdata/config/reports/ folder under folders named html,xml etc.

logsInfo attribute

Both DSahiRunner and TestRunner take multiple parameters to define how the tests are executed.
To specify logging, one needs to add the logsInfo parameter as given below:
-logsInfo "<logType>[:<logFolder>],<logType2>[:<logFolder2>]"

For example, to enable file system based logging in HTML and XML formats, add

-logsInfo "html:D:/pathto/htmlLogs,xml:D:/pathto/xmlLogs"

This will create:
html logs in D:\pathto\htmlLogs and
xml logs in D:\pathto\xmlLogs

If no paths are given, like,
-logsInfo "html,xml,tm6"
the logs will be created in a default timestamped location in userdata/logs/ with html,xml and tm6 subfolders

To specify location only for some log types, use something like
-logsInfo "html,xml:C:/xml,tm6"
xml logs will be logged to C:/xml, while html and tm6 will go into default timestamped location in userdata/logs/ with html, tm6 subfolders.

Understanding reports and report types

The words html and xml are not special keywords. These can be defined by the user.
When Sahi sees the logType as html, it will look for a folder
sahi_pro/userdata/config/reports/html.

This folder contains various XSL files for transforming data as desired, and a report.properties file.

A brief description of various XSL files:

script_report.xslOutput for individual scripts
suite_report.xslOutput for a single suite
suites_list.xslCreates the default listing of all suites (This may only be needed by the default online reporting)
testcase_report.xslCreates the output for individual scripts but also shows summary of testcases (Refer _testcase() API)
reconciled_report.xslOutput for different view of data. For example, to show stepwise time comparisons in a load test

The names of the output files can be governed by the entries in report.properties Eg.
script_file.name=<reportId>.html
suite_file.name=index.html
images.copy=true
images.dir=images

Variables available are <scriptName> and <reportId> and will be replaced correctly in the file names.
images.copy tells Sahi whether screenshots images should be copied and images.dir specifies the copy destination folder.

Adding logsInfo in testrunner.bat

Open sahi/userdata/bin/testrunner.bat. Look for
SET LOGS_INFO=
and change it to
SET LOGS_INFO=html:D:/pathto/htmlLogs,xml:D:/pathto/xmlLogs

Adding logsInfo in drun.bat

Same as for testrunner.bat

Adding a new custom reporting type


Copy
userdata/config/reports/html
to
userdata/config/reports/mytype

Edit the xsl files as desired. You can test your xsl at runtime by navigating to any existing logs and adding &type=mytype at the end of the log url.

For example, click on the "Logs" link on the dashboard and drill down to any particular script report.

You may see a URL like this on the browser address bar:
http://localhost:9999/_s_/dyn/pro/DBReports_scriptReport?id=clicksTest__03Nov2011__09_17_36
Add &type=mytype to the end such that it looks like
http://localhost:9999/_s_/dyn/pro/DBReports_scriptReport?id=clicksTest__03Nov2011__09_17_36&type=mytype
This will show you your modified output according to the xsl in mytype folder.

When ready with the correct XSL, open testrunner.bat or drun.bat and pass -logsInfo=mytype.
You will now see the logs created according to your xsls.

warning The older variables in sahi.properties/userdata.properties are no longer honoured:
reports.filesystem.html.enabled=true
reports.filesystem.xml.enabled=true
reports.db.enabled=true
reports.sql.enabled=true