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.- All report data is stored in the database by default.
- At the end of a suite, Sahi Pro reads the data from the database and converts them to XML
- 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 insahi_pro/userdata/config/reports/
folder under folders namedhtml
,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
andxml 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
subfoldersTo 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 wordshtml
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 foldersahi_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.xsl | Output for individual scripts |
suite_report.xsl | Output for a single suite |
suites_list.xsl | Creates the default listing of all suites (This may only be needed by the default online reporting) |
testcase_report.xsl | Creates the output for individual scripts but also shows summary of testcases (Refer _testcase() API) |
reconciled_report.xsl | Output 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
Opensahi/userdata/bin/testrunner.bat
. Look forSET LOGS_INFO=
and change it toSET LOGS_INFO=html:D:/pathto/htmlLogs,xml:D:/pathto/xmlLogs
Adding logsInfo in drun.bat
Same as for testrunner.batAdding 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 likehttp://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
reports.filesystem.html.enabled=true
reports.filesystem.xml.enabled=true
reports.db.enabled=true
reports.sql.enabled=true