Reports are vital part of any automation testing and with Selenium+TestNG framework we have the default TestNG reports, which some consider to be a little out of date... to over come this, we have a add on report for TestNG know as TestNG-XSLT which gives good graphical representation of the generated report.
TestNG-xslt generates user friendly reports using the TestNG results output (testng-results.xml). Its uses the pure XSL for report generation and Saxon as an XSL2.0 implementation.
For generating testng-xslt report for your project do the following:
1. Download the testng-xslt from
http://code.google.com/p/testng-xslt/
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. Modify your build.xml of ant and add the following target to it.
You need to provide the testng-xslt stylesheet the TestNG results xml(testng-results.xml) , the path to the style sheet testng-results.xsl and the output index.html path.
Also dont forget to add the saxon library to your target classpath else you will get an error. In my case it is the master-classpath.
Now run the ant target for report generation (in this case "testng-xslt-report") and check the ouput folder configured by you for testng-xslt report.
TestNG-xslt generates user friendly reports using the TestNG results output (testng-results.xml). Its uses the pure XSL for report generation and Saxon as an XSL2.0 implementation.
For generating testng-xslt report for your project do the following:
1. Download the testng-xslt from
http://code.google.com/p/testng-xslt/
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. Modify your build.xml of ant and add the following target to it.
<project name="test" basedir=".">
<property name="LIB" value="${basedir}/libs" />
<property name="BIN" value="${basedir}/bin" />
<path id="master-classpath">
<pathelement location="${BIN}" />
<fileset dir="${LIB}">
<include name="**/*.jar" />
</fileset>
</path>
<target name="testng-xslt-report">
<delete dir="${basedir}/testng-xslt">
</delete>
<mkdir dir="${basedir}/testng-xslt">
</mkdir>
<xslt in="${basedir}/test-output/testng-results.xml" style="${basedir}/testng-results.xsl" out="${basedir}/testng-xslt/index.html">
<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">
</classpath>
</xslt>
</target>
</project>
You need to provide the testng-xslt stylesheet the TestNG results xml(testng-results.xml) , the path to the style sheet testng-results.xsl and the output index.html path.
Also dont forget to add the saxon library to your target classpath else you will get an error. In my case it is the master-classpath.
Now run the ant target for report generation (in this case "testng-xslt-report") and check the ouput folder configured by you for testng-xslt report.
hai, can u tell me what are all the settings needs to be made in made in POM.xml while creating the testNG xslt report using maven alone.
ReplyDeletehi Janardhana,
DeleteCan you please post your pom.xml here. I shall review it and try to help you..
This comment has been removed by the author.
DeleteHI NX, i m not able to post my entire POM.xml in ur site .its getting badly restructured after i posting it....
ReplyDeletei shall get back to you... dont worry, we can over come the issue you are facing.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletehere is the snippet of POM.xml. If i execute it only the sure fire report is created but not the testng-xslt report and also i dont know where exactly i sud put testng-xslt file. right now i put it in directory where POM.xml resides.
ReplyDeleteorg.testng.xslt
testng-xslt-plugin
1.1
Maven-TestNG-Demo-1/target/site/
true
Good example!
ReplyDeleteHello everybody, I need help, getting src\testng-results.xsl:690: Fatal Error! Failed to create output file file://///Suite.html Cause: java.io.IOException: The specified path is invalid
ReplyDeleteHi Maksim,
Deletewhen are you getting this error message? are you trying to run the scripts using suit xml or the build xml? please give more details, so that we can help you.
This error happen if we for get to mentioned param expression="${basedir}/testng-xslt/" name="testNgXslt.outputDir" this is mandatory and must be an absolute path.This is mandatory and must be an absolute path.
DeleteFor more details go this links: http://startingwithseleniumwebdriver.blogspot.in/2014/03/some-error-and-solution-for-testng-xslt.html
Ni NX,
ReplyDeletethanks a lot for response,
I am running the build.xml I have changed the
to my ...xsltRepors/output/Suite.html path and it does not throw an error I did the same for
-overview.html
-reporterOutput.html
-navigation.html
-style.css
-main.js
-overview-chart.svg
and it saves all these files in ...xsltReports\output directory
the second obstacle that I am getting: I do not see "Suite Name".html, "Groups".html, "Test Name".html also Reporter output page is blank.
Any idea what I am doing wrong? Could you please help me?Thanks!
Changed the absolute path of Suite.html and others to myProjectPath/xsltReports/output dir
Deletexsl:result-document href="{testng:absolutePath('Suite.html')}" method="xhtml
ReplyDeletePlayed with absolutePath, and now all looks good except Reporter Output, as I mentioned before it displays blank page
ReplyDeleteCan you please attach a screen shot of your framework pointing out the position of your Reporter out in the framework?
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteHai i need Hybrid Driven frame work java code, its urgent and i need code how to crearte our own reports with Screen shots while error and how to mail our reports through our code. am struch in these areas, but now i need to do this very quickly. pls help me reg this. and one more thing is that i have excel read code and keywords.xls and data.xls but while ececuting am getting these error, and not able to proceed. pls help me reg this urgently pls. Here am posting the error also.
ReplyDeleteException in thread "main" java.lang.RuntimeException: There are no support for this type of cell
at WebdriverAutomation.firstautomation.cellToString(firstautomation.java:197)
at WebdriverAutomation.firstautomation.excelRead(firstautomation.java:167)
at WebdriverAutomation.firstautomation.main(firstautomation.java:33)
iam having excelRead()function with in the same class and am assign it to a 2 dimentional array called steps of type String[][]. like String[][] steps = excelRead(); here am getting error.
ReplyDeleteHi Gouri,
DeletePlease give me some time, i am a little busy with my work now, will have a look at your issue by evening and get back.
Thanks for the reading my blog.
Pls help me reg this issue am in very urgency, pls any one can help me pls
ReplyDeleteunable to access http://code.google.com/p/testng-xslt/ giving below error:
ReplyDelete403. That’s an error.
Your client does not have permission to get URL /p/testng-xslt/ from this server. That’s all we know.
Hi , I am getting this error and following is the my code:
ReplyDelete411: Fatal Error! Failed to create output file file://///style.css Cause: java.io.IOException: The filename, directory name, or volume label syntax is incorrect..
This error happen if we for get to mentioned param expression="${basedir}/testng-xslt/" name="testNgXslt.outputDir" this is mandatory and must be an absolute path.This is mandatory and must be an absolute path.
DeleteFor more details you can go this links http://startingwithseleniumwebdriver.blogspot.in/2014/03/some-error-and-solution-for-testng-xslt.html
hi..i am writing script in apache ant and my output is in the form of a text.. how can i convert it into xml and then modify the report using testng xslt..
ReplyDeleteIm trying to include xslt reports in my Testng framework with ant. When I try to execute the the MakeReport target in build.xml I get some error related to classpath saying Reference test.classpath not found for SaxonLiaison
ReplyDeleteI have not gone with your method, because I Dont want to copy the SaxonLiaison Jar files to my project.
Please help on how to solve this issue. i tried everything.
Can you please tell me which folder are you referencing to when you say "your project lib folder." I dont find any project lib folder to copy saxonLiaision
ReplyDeleteCan you post the exact error message that you are getting?
ReplyDeleteHi.. I have created xslt reports using ant and build.xml
ReplyDeleteHowever the reporter output is not clear. All the logs from different tests are logged continuously. Is there any way of sepearting it for different @Test.
Also how to generate screen shots for failed testcases?
Can u please tell me how to add screenshots in detail(like folders we have to create and all those things )please help me out.
ReplyDeleteThanks in advance
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 anyone share the build.xml code?
ReplyDeleteHi NX,
ReplyDeleteCan u plz tell me how to integrate POM.xml with testNG-xslt fro xslt reports
hey Vishvajeet did you figure out how to integrate maven and xslt please update if you know how todo.
Delete