Monday, 21 January 2013

XSLT- Generate Interactive reports on TestNG+ANT

XSLT stands for XML (Extensible Markup Language) Stylesheet Language for Transformations.
XSLT gives interactive(user friendly) reports with "Pie Chart"; but only on TestNG framework. It is better compared to ReportNG and ordinary TestNG reports. It uses the pure XSL for report generation and Saxon as an XSL2.0 implementation.

XSLT = XSL Transformations

Steps to Generate testng-xslt report:

1. Download
2. Unzip and copy the testng-results.xsl from the testng-xslt folder(testng-xslt-1.1\src\main\resources) to your own project folder.
3. Now copy the saxon library from (testng-xslt-1.1\lib\saxon-8.7.jar) to your project lib folder.
4. Make sure Guice-x.x.jar is available in the build path. [As shown in my GIT]
5. Modify your build.xml of ant and add the following target to it.

<?xml version="1.0" encoding="UTF-8"?>
        <project name="automation" default="Run" basedir=".">
<property name="src.dir" value="${basedir}/src"/>
<property name="build.dir" value="${basedir}/build"/>
<property name="testng_output.dir" value="${basedir}/testng_output"/>

<!-- get class path, used for build -->
<property name="lib.dir" value="${basedir}/lib"/>
<path id="classpath">
        <fileset dir="${lib.dir}" includes="*.jar"/>
<pathelement location="build"/>

<!-- create build folder, testng_output folder and remove old log file -->
<target name="init">
<delete dir="${build.dir}"/>
<delete dir="${testng_output}"/>
<delete dir="${basedir}/testng-xslt"/>
<mkdir dir="${build.dir}"/>
<mkdir dir="${basedir}/testng-xslt"/>
                <mkdir dir="${testng_output.dir}"/>

<!-- build all java file to class binary -->
<target name="compile" depends="init">
   <javac srcdir="${basedir}/src" destdir="${basedir}/build" classpathref="classpath" includeantruntime="false">
   <compilerarg value="-Xlint:unchecked"/>

<!-- Config for testng -->
<taskdef name="testng" classname="org.testng.TestNGAntTask">
    <pathelement location="lib/testng-6.8beta.jar"/>

<!-- execute testng after compile, then generate report -->
<target name ="Run" depends="compile">

<!-- config testng -->
   <testng outputdir="${testng_output.dir}" classpathref="classpath" useDefaultListeners="true">

    <!-- execute testcase follow testng.xml -->
    <xmlfileset dir="." includes="testng.xml"/>
    <!-- generate report title -->
    <sysproperty key="org.uncommons.reportng.title" value="Test Automation"/>
    <sysproperty key="org.uncommons.reportng.escape-output" value="false"/>
<target name="xslt" depends="Run">
   <xslt in="${basedir}/testng_output/testng-results.xml" style="${basedir}/testng-results.xsl" out="${basedir}/testng-xslt/index.html" processor="SaxonLiaison">
            <param expression="${basedir}/testng-xslt/" name="testNgXslt.outputDir" />

            <param expression="true" name="testNgXslt.sortTestCaseLinks" />

            <param expression="FAIL,SKIP,PASS,CONF,BY_CLASS" name="testNgXslt.testDetailsFilter" />

            <param expression="true" name="testNgXslt.showRuntimeTotals" />

            <classpath refid="master-classpath">

<property name="LIB" value="${basedir}/lib" />
<property name="BIN" value="${basedir}/bin" />
<path id="master-classpath">
<pathelement location="${BIN}" />
      <fileset dir="${LIB}">
         <include name="**/*.jar" />


5. Create TestNG.xml file in your project with the following script for TestNG execution.

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite" parallel="false">
  <test name="Test">
      <class name="package.classname"/>
  </test> <!-- Test -->
</suite> <!-- Suite -->

6. Now, try to run the command.

ant xslt


  1. Hi Prashanth,

    I am running the same script that you have given here.
    It is running and giving message as build successful.
    But I am not able to find the report generated folder testng-xslt any where.

    Please help on this.
    Thanks in advance.

  2. Hi Prashanth,

    I fixed the issue. Your code previously seem to be pointing to wrong directory and also you are trying to run Report NG as well as Test NG.
    XSLT seem to be formatting only Test NG out put.

    Your blog is really nice for the beginners to work with reports.

    Thank you.

  3. Thank you Suresh! I fixed the code; seems it is working for you right now.

    Enquire me for any issues

    Thank you!
    Prashanth Sams

  4. Hi Prashanth,

    Thanks for such a informative blog..
    When i am using the above code, i am getting following error:


    Please let me know how to resolve it.

  5. Shankar, This might have happened due to version capatibility sickness; Please check your ANT version and update it.

    Environment Varibles
    Under System variables:

    variable name: ANT_HOME
    variable value: C:\Program Files\Apache Software Foundation\apache-ant-1.8.4

    Add ur Path
    C:\Program Files\Apache Software Foundation\apache-ant-1.8.4\bin;

    Check ANT version

    cmd > ant -version

    Please lemme know on any issues ;)

    Thank you!
    Prashanth Sams

  6. hi Prashanth,

    Please let me know from where i can download Xslt code ?


    1. Jagadeesh, Try to use the above link for downloading xslt code now.


  7. Hi Prasanth sams

    very nice article.
    my build.xml is executing only the HtmlUnit driver.It is not even opening other browsers like firefox for chrome.

    can you please tell me what would be the reason?


  8. Aruna, Can you able to launch test through Firefox on normal eclipse IDE using JUnit/TestNG ?

    If yes, Please send me your xml file to


  9. Hi Prashanth,

    I am getting unusual error, "[xslt] Unknown file:23:146: Fatal Error! Could not find function: if", however i am just using same xslt as on github site, but i am stuck , will be obliged if you could help me to get out of this confusion. Let me know if you need any more detail.
    Any help would be appreciated.


    1. Try to run the testng.xml first to make sure everything works fine.
      Then go with ant build.xml
      Checkout my example on GIT for newbies:


  10. Hi Prashanth,

    I have created an ant script with targets for my project automation. I want to generate report for it using xslt. Please help me how can I inculde this xslt code in my test xml file. I am running ant script in alinux server with the help of a shell script.

  11. Hi,

    I am getting an error message (BUILD FAILED) when i run the build.xml using the code i got from the internet.

    Can someone help me

  12. am using selenium webdriver java build [ latest one]

    Framework : TestNg

    Editor Eclipse

    Firefox browser version : 22.0

    Chrome Browser version : 28.0.1500.72 m

    OS: Windows 7 Ultimate

    From Eclipse run option my test cases are running properly but When ever i am trying to run my webdriver test cases from command prompt using ANT

    For the chrome browser it showing alert related to manifest version and for Firefox browser its showing error related to Unable to bind to locking port 7054.

    Can any one give some suggestion what changes are required so that i can run my test cases properly from ant

  13. I am getting the below error
    C:\Users\amodak\Vecna_Sample\Vecna_Test\build.xml:28: C:\Users\amodak\Vecna_Samp
    le\Vecna_Test\LIB does not exist.

    In eclipse I have created 3 Library namely
    1. JRE System Library - Pointing to JRE jars in C:\Program Files\Java\jre7\lib
    2. TestNG - pointing to D:\Softwares\eclipse\plugins\org.testng.eclipse_6.8.6.20130607_0745\lib\testng.jar
    3. LIB - D:\Selenium LIB\selenium-java-2.33.0\selenium-2.33.0\selenium-2.33.0\selenium-2.33.0\libs\Selenium jars

    Please suggest the needful

    1. Ayan, please make sure all the lib files are there in your classpath.
      Please check my git
      Download, import in Eclipse and run them


  14. Team ,

    if you have idea please let me know

    [testng] Exception in thread "main" Guice provision errors:
    [testng] 1) null returned by binding at org.testng.internal.TestNGGuiceModule.provideObjectFactory()
    [testng] but org.testng.internal.Configuration.m_objectFactory is not @Nullable
    [testng] while locating org.testng.IObjectFactory
    [testng] for field at org.testng.internal.Configuration.m_objectFactory(
    [testng] while locating org.testng.internal.Configuration
    [testng] at org.testng.internal.TestNGGuiceModule.configure(
    [testng] while locating org.testng.internal.IConfiguration
    [testng] 1 error
    [testng] at$4.get(
    [testng] at
    [testng] at org.testng.TestNG.getConfiguration(
    [testng] at org.testng.TestNG.createSuiteRunner(
    [testng] at org.testng.TestNG.createSuiteRunners(
    [testng] at org.testng.TestNG.runSuitesLocally(
    [testng] at
    [testng] at org.testng.TestNG.privateMain(
    [testng] at org.testng.TestNG.main(
    [testng] The tests failed.

    1. This issue is due to GUICE jar file not there in location..please download Guice jar and place in exact location..Try..

  15. Hi Prashant,
    please can you tell me how to delete Old output folder under the TestNG Report.

    1. It will automatically delete all the old files generated in previous run; I have set it in build.xml.
      Hope you have gone through that.

  16. Sir (lib/testng-6.8beta.jar) this file path i am not understand what is this path its fix ya change my pc path seting

    1. You don't need to worry about this jar file; Cos, the latest selenium servers comes with in-built TestNG libraries.


    2. Hi Prashanth,

      I am getting taskdef class org.testng.TestNGAntTask can not be found error while compilation.
      Can you please help me out

  17. HI prashant,
    what is the use of configuring testng and passing className as

    where is the this TestNGAntTask class present?
    after removing the code, everything working fine,build was successfull.but i am not getting xslt report? what would be the reason?

    1. Khamer, It allows to configure TestNG when you try to execute the tests using ANT.
      May be you're missing one of the above mentioned steps..I've explained everything in a sample project on github

      Prashanth Sams

  18. Hello Prashanth,
    Very nice tutorial. Is it possible to print user defined messages in XSLT reoprt. For example If i am executing Login test, I want to print What all steps performed inside that test. Whether that step was successful or not.

    Reporter.Log shows logs for Complete Test suite. But I want to have cusomised for each testcase

  19. This comment has been removed by the author.

  20. Hi
    very use full for every selenium people
    please can u tell where I can store testng-results.xsl file in my project
    I am using java 1.7 and selenium Web driver 2.37 this build.xml provided by u it will work or not please replay me I am waiting ur answer

    1. Ranjan, you can store the .xsl file inside your project folder.

  21. Hi Prashant,
    Thanks for the blog. I used this in my project to generate xslt report, but now I want to send this report in the email body. Since the index.html file generated here has dependency on many other html files in output folder, is there any way to send this in email body?
    Your help is much appreciated.

    1. Hi Vijay, I will make sure "Emailing XSLT Test reports - Ant" ASAP in this post.

  22. Hi Prashanth,Wonderful Post.Thanks a LOT for sharing this information with us.Please continue with your Great Work.You are sharing your knowledge and experience with us.May GOD BLESS YOU...

  23. Hi Prashanth Sams, I have tried to configure the project that you shared with us in the following url( and it worked for me after initial glitches. We have to update the Selenium Jars to latest ones and try again.It will work.Thank You for your support for beginners like us.Please keep up the Good Work.May GOD BLESS You...

  24. Hi Prashanth Sams, I ran the above script as per what you have given.After making some changes(like updating the jar files),it ran well.Thank You for guiding us.Please keep up the Good Work.May GOD BLESS YOU... :)

  25. Am using selenium webdriver (ANT+TestNG+Java).How do I save results of TestNG with time-stamp and build no.(testng-results-Build no:DD-MM-YYYY_HH-MM-SS.xml),without overwriting previous results. Could you please share the build.xml code?

  26. Hi Prashanth,

    I really appreciate the effort you put in all your blogs.

    I am not using Ant , Eclipse+Webdriver+TestNg , is it possible to generate xslt reports ? if yes, could you please guide me.


  27. This comment has been removed by the author.

  28. Hi Prashant ,

    when I run the code, I am getting an error -"No srcDir specified" in the below line-
    testng outputdir="${testng_output.dir}" classpathref="classpath" useDefaultListeners="true"

    Please suggest me what could be the possible way to get rid of this error.


  29. Hi,
    I am using XSLT reports, But facing an issue
    1) When I open XSLt reporst with Firefox it works fine
    2) When I open it from Chrome the checkbox like Failed passed, Skipped are not working.

    Please let me know the solution.

  30. Hi Prashant,

    We have a small requirement asked by our client that is

    We are able to generate the high level testng report with the help of .xsl file and even we are mailing to stake holders. But now they are asking us to keep the pie diagram of the high level report in the mail body.

    Is there any way we can fetch and keep the pie diagram in the mail body.

    Thanks in advance,

    1. Yatheesh,

      There is no existing reporting system for such requirements. Currently, I am creating a new report for Selenium called SRF, Selenium Reporting Framework. I will try to implement them in it. Stay Tuned!!


  31. Hi Prashanth,

    Very nice blog,it makes me to create a XSLT Report very easy, Thanks a lot

    1. Thank you :) Stay Tuned for SRF, Selenium Reporting Framework.

  32. Hi I am Completey New to Automation and trying to my way to figure things around.

    I have few tests written in Test NG and looking out for generating a xlst report, i have ant installed in my computer

    Now what happens can i generate a Ant Build .xml from eclipse or do i have to code it, please help me out on how to proceed further.

  33. Hi Prashanth,
    I trie your blog. It is very informative. I do same .
    But my build is nOT successful.
    It gives error:

    C:\Eclipse\SBC Regression\SBC\build.xml:33: taskdef class org.testng.TestNGAntTask cannot be found
    using the classloader AntClassLoader[]

    Can you please tell me what may be the cause

  34. Hi Prasanth,

    I am getting below error.

    I added all jars in testng.xml its working absolutely fine. but build.xml i am getting below error...
    [javac] Compiling 2 source files to D:\Selenium_Automation\Selenium_Practice\TestNG_XSLT\build
    [javac] D:\Selenium_Automation\Selenium_Practice\TestNG_XSLT\src\report\ error: package org.openqa.selenium does not exist
    [javac] import org.openqa.selenium.WebDriver;
    [javac] ^
    [javac] D:\Selenium_Automation\Selenium_Practice\TestNG_XSLT\src\report\ error: package org.openqa.selenium.firefox does not exist
    [javac] import org.openqa.selenium.firefox.FirefoxDriver;
    [javac] ^


    Please help me in this....

  35. Hi Prashanth,

    Thanks for the blog just joined here.
    What exactly in Reporter output contains on above Graph?

  36. Hi,

    It was really helpful. But my query is how can I view browser or operating system used in this xslt report?

    My client wants to see parameters like os, browser details in the report.

    Looking forward for your reply!


  37. Hi I am copying your complete code to build.xml file. and running through RUN TEST (windows batch file ), its not running. Please help me for this.

  38. i am also getting the same error when i am running my suite from build.xml and suite.xml working exaclty fine

  39. Unknown file:23:146: Fatal Error! Could not find function: if--- getting this error when i am running my suite from build.xml and suite.xml working exaclty fine

    1. hi neha,
      if you found the solution then can you please post it here?

  40. nice tutorial, to generate pdf report use pdfngreport its free,open source plugin library

  41. Did anyone found the solution for Fatal Error

    [xslt] Unknown file:22:146: Fatal Error! Could not find function: if
    [xslt] : Fatal Error! Fatal error during transformation Cause: Fatal error during transformation

    I am able to run test successfully and testng reports are also generated. but when I am generating xslt report. I am getting fatal error.

  42. This comment has been removed by the author.

  43. Hi Prashanth,

    I am able to run my application through testng.xml successfully but not able to run using ant build. It is showing below mentioned text :
    [testng] Total tests run: 1, Failures: 0, Skips: 1
    [testng] Configuration Failures: 1, Skips: 1
    [testng] ===============================================
    [testng] The tests failed.
    Total time: 6 seconds
    Actually it is showing skipped status. Please suggest

  44. I am able to run target(init,compile) successfully independently but not able to run Run target.

  45. Hi Prashanth,

    Thanks for this post. I would like to know how I will generate a XSLT report in testng without ANT or Maven?

    Thanks and Regards,

  46. Hi prashanth,i created build and it runs successfully and the folder which i wanted to store the xslt reports is also created but the report of xslt is not there in that folder..can u help me where it will be and how i can see it???

  47. I have successfully implemented using the steps mentioned here. However i need help to make some changes. I would like to add logo of our client top left corner of the generated report.

  48. I have successfully implemented using the steps mentioned here. However i need help to make some changes. I would like to add logo of our client top left corner of the generated report.

  49. shashikant sabnekar22 December 2015 at 21:50

    I have successfully implemented using the steps mentioned here. However i need help to make some changes. I would like to add logo of our client top left corner of the generated report.

  50. Interactive Property Solution iBrouchure with numerous exceptional capacity to make your undertaking intriguing. It tells the story and interactive.

  51. Sometimes xslt reports are not generating proper results like even if any failures are there its showing as pass, did anyone faced this issue.

  52. Thanks for the great information in your blog Selenium Training in Chennai

  53. Hi its great blog and nice. I have one question - I have developed a keyword driven framework. I have one @test method and all my logic sits there for excel. How do I utilize XLST report because it shows only one test in report

  54. Hi, i want to share xslt index.html file with my teammates but they are unable to see the report. Cant it be opened like emailable file generated by testng.

  55. Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
    Advanced AWS Training in Bangalore | Best Amazon Web Services Training Institute in Bangalore
    Advanced AWS Training Institute in Pune | Best Amazon Web Services Training Institute in Pune
    Advanced AWS Online Training Institute in india | Best Online AWS Certification Course in india
    AWS training in bangalore | Best aws training in bangalore

  56. Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article. thank you for sharing such a great blog with us.
    microsoft azure training in bangalore
    rpa training in bangalore
    best rpa training in bangalore
    rpa online training

  57. Really very nice blog information for this one and more technical skills are improve,i like that kind of post.
    Best Devops online Training
    Online DevOps Certification Course - Gangboard

  58. Really great post, I simply unearthed your site and needed to say that I have truly appreciated perusing your blog entries.
    Python Online certification training
    python Training institute in Chennai
    Python training institute in Bangalore

  59. Thanks For Sharing The Information The Information shared Is Very Valuable Please Keep Updating Us Time Just Went On reading The Article Aws Online Course Python Online Course Data Online Course Hadoop Online Course

  60. Great Article… I love to read your articles because your writing style is too good,
    its is very very helpful for all of us and I never get bored while reading your article because,
    they are becomes a more and more interesting from the starting lines until the end.
    python online training