Reports
abstract
When a suite or script is executed, detailed reports of suite, script, steps and errors are automatically created by Sahi and stored in a database.
Reports can be viewed as a web page, or downloaded as offline files in various formats. Reports can also be synced to a central database or between Sahi installations.
The appearance of reports can be modified via XSL style sheets. Various other parameters of reports can be also be configured.
Sahi Statuses
Status | Description | Color |
---|---|---|
SUCCESS | Scripts which has passed all the steps or test cases. | GREEN |
FAILURE | Scripts which has at least one step or test case failed. Assertion failure, Syntax error also come under this. | RED |
ABORTED | When browser hangs or goes unresponsive for certain period of time. Default is 90 second. | BROWN |
SKIPPED | Scripts which are skipped from execution due to depended scripts failure. Refer Data driver suite section. | GREY |
NOT_SUPPORTED | Scripts which are not executed due to unavailability of required resources. | DARK GREY |
USER_ABORTED | Occurs when script execution has stopped manually by user through | BROWN |
RUNNING | Scripts which are still in execution state. | YELLOW |
Report Screens and Navigation
- To view the script execution logs, click on "Logs" link from either Sahi Editor or Sahi Controller or navigate to http://localhost:9999/logs
This shows the Suites List page. - Consolidate Report: Click on Consolidate Report to get a consolidated report of Scripts and Testcases of selected Suites.
- Click on Suite or Script to view the Suite Report page.
Suite reports are displayed as a nested tree structure of suites and scripts.
It shows the exact nested level for scripts the way it is written in suite / dd.csv file so that user can get the idea of which script belongs to which suite / dd.csv file.
Offline reports will also look as nested tree structure.
- Click on any individual script to view the Script Report page.
- The steps which failed during script execution will be in shown in red color, with an error message, stating the reason for the step failure.
- Sahi takes screenshots on step failures and errors. Screenshots give visual information on the state of the application during failure.
Click on
onScriptErrorDefault
to view the screenshot. - Clicking on a line in the logs will drill down to exact line in script.
- To edit the script, click on
Edit Script
. Sahi Editor will be opened.
Downloading reports
Multiple suite reports can be downloaded directly from the logs page. One can set the report type from the "Download as" dropdown.The reports can be downloaded with varying formats including email, html, xml, excel, junit, tm6.
One can also download multiple script reports inside a suite, if there exists any script inside that suite.
Auto Refresh Logs
Check the auto-refresh checkbox to automatically refresh the page to show current status of suite. The logs page will refresh every 2 seconds till the excecution completes.Javascript Code Coverage Reports
Clicking onJS Code Coverage Report
link on Suite and Script Reports pages, shows code coverage reports.
Refer: JS Code Coverage Report section for details.
Suite Analysis
Clicking onSuite Analysis
link on Suite and Script Reports pages, shows code script failure reports.
Refer: Suite Analysis section for details.
Reports - Architecture and Flow
When a script is executed, steps 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 in
sahi_pro/config/reports/
folder under folders namedhtml
,xml
etc.
Understanding reports and report types
Sahi Pro reports can be generated and downloaded in various report types. By default, Sahi Pro ships withhtml, xml, junit, excel and email
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
userdata/config/reports/html
or in 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. (Testcases are defined in Scenario files.) |
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 are defined 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.
Modifying an existing reporting type
Reports are generated using XSLs. XSL files are by default in subfolders ofconfig/reports/
.
They can be overridden in userdata/config/reports/
folder
Sahi will first look for any report xsl in
userdata/config/reports/
.
If it is not found, it will default to config/reports/
For example, xsls for
html
reports are in config/reports/html
folder.
To modify existig xsl, copy it over into
userdata/config/reports
with the same subfolder name.
Eg. if you want to modify
config/reports/html/suites_list.xsl
, copy it such that you have
userdata/config/reports/html/suites_list.xsl
.
Now modify this copied file as needed.
Adding a new custom reporting type
To create a new log type copyconfig/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.
Report Customizations
Sort suite report
By default the suite report will be sorted by script STARTTIME, but if user wants to sort the suite report by SCRIPTNAME, follow the below steps.- Take a backup of
config/reports/html/suite_report.xsl
. - Open
config/reports/html/suite_report.xsl
- Search for
and uncomment it.<!-- <xsl:sort select="SCRIPTNAME" /> -->
Add custom fields in Suite reports
From Sahi Pro v6.3.0, user can add custom fields in Suite report as well. Suppose you need two custom fields: customField and anotherCustomField- Take a backup of
config/reports/html/suite_report.xsl
. - Open
config/reports/html/suite_report.xsl
-
Custom field headers
search for
and change it to<!-- Custom Field header--> <!--<td id="RowNo">Custom Field</td>-->
<!-- Custom Field headers--> <td id="CustField1">Custom Field</td> <td id="CustField2">Another Custom Field</td>
-
Custom field values
search for
<!--Retrieve custom field value--> <!-- <td> <xsl:if test="$suiteInfo != 'null'"> <pre><xsl:value-of select="util:fetchInfo($suiteInfo, 'customField')" /></pre> </xsl:if> </td> -->
infoNOTE: There will be two occurences for Retrieve custom field value. Make sure you replace at both occurences.and change it to<!--Retrieve custom field values--> <td> <xsl:if test="$suiteInfo != 'null'"> <xsl:value-of select="util:fetchInfo($suiteInfo, 'customField')" /> </xsl:if> </td> <td> <xsl:if test="$suiteInfo != 'null'"> <xsl:value-of select="util:fetchInfo($suiteInfo, 'anotherCustomField')" /> </xsl:if> </td>
info NOTE: Add as many entries as there are custom fields.
-
Custom field headers
search for
Set pass threshold percentage for Suite or Data Driven Suite
From Sahi Pro v7.5.0, user can set pass threshold percentage for Suite or Data Driven Suite. Suppose the user need to see log result as success for more than 75% in the scripts of a suite or dd.csv, then the user can set pass threshold percentage to 75%.- Click the
Configure
link on Sahi dashbord and go touserdata properties
. - Then select
sahi properties
and search for sahi.pass_threshold_percentage. - The default value is set to 100, update the value as required.
Offline logs for Controller Playback
By default offline logs are not created for playback via Controller. If needed, offline logs for playback via Controller can be specified inuserdata.properties
by setting controller.offline_logs.type
property
# Sets the type of offline logs created when script is run from Controller. Set to blank to disable offline logs
controller.offline_logs.type=html
Deleting DB reports
If you want to delete the unwanted logs and reduce the size of database, follow the below procedure:- Close Sahi(if running).
- Open a command prompt and cd to
sahi_installation_folder/userdata/bin
- Run delete_reports.bat/delete_reports.sh to see the syntax
D:\SahiPro\userdata\bin>delete_reports.bat -- Usage: delete_reports.bat "-duration=<duration_in_number_of_days>" Example: To delete reports older than 30 days: delete_report.bat "-duration=30" The duration_in_number_of_days is greater than or equal to 0. -- D:\SahiPro\userdata\bin>