Showing posts with label ANT. Show all posts
Showing posts with label ANT. Show all posts

September 3, 2015

Generate XSLT reports for Webdriver scripts using ANT build.xml

September 03, 2015 3
This is continuation of my previous post Ant-with-selenium-webdriver-and-testng.html 

In previous post i explained how to integrate ant with selenium and testNG. In this post i will explain how to Generate XSLT reports using Ant.

Need of  XSLT reports:

Till now we are relying on reports generated by testNG. But those reports are not much interactive. XSLT reports are very interactive and easy to understand. Below is sample report.



Steps to Configure XSLT reports:

Prerequisites:
1. SeleniumWebdriver Project developed using ANT. If you want you can download it from here.

Ant_SeleniumWebdriver_TestNG

2. Download XSLT from here Download XSLT

Configure XSLT:


  1. Download testng-xslt-1.1.2-master.zip and unzip it 
  2. Copy all jar files and place them in jar library folder in your project.
  3. Copy the testng-results.xsl from the testng-xslt folder(path: XSLT jartestng-xslt-1.1.2-mastertestng-xslt-1.1.2-mastersrcmainresources) and place in your project folder.
  4. Modify xml code in build.xml


Below is updated build.xml file. which has xslt code included.



How to Generate XLST Reports:

To generate XSLT report you need to run build.xml file and need to check the task check box (makexsltreports) then report will be generated under your project with folder Name --- XSLT_Reports---output--index.html

Below is folder path screenshot:

Below is sample report: (PASSED)



Run From Command prompt:

You can run makexsltreports task from comamnd prompt also. Here is the way to run
Navigate to projetc folder from command prompt and type in --- ant  

ant makexsltreports

I updated  code to generate failed report.

Below is failed report:




Click on Test which is under TestNG Results.
Click on Failed test case method name (testTC2()). and click on exception..it will show you details about exception.



You can download project Here ... ANT_Webdriver_TestNG_XSLT




August 25, 2015

ANT with Selenium Webdriver and TestNG (Selenium Ant TestNG)

August 25, 2015 0
In this article i would like to write something about Build tool ANT. http://ant.apache.org/

A build tool stores, executes automates all the process in a sequential order(Clean, SetPath, Compile and Execute) mentioned in Ant's build.xml file.


Benefits of ANT:

1. It is a simple build tool all configurations we can do from build.xml file.
2. Configuration is separate from application.
3. ANT is written in Java but its a platform independent tool. (Requires JDK)
4. We can create Jar files, Java doc.
5. Copy files to different locations
6. Can create directories and folders
7. Can create HTML reports.
8. It supports Junit4 and TestNG unit testing frameworks.

How to Setup ANT:

1. Download ant from  Download ANT





2. Unzip ant folder and place it in a folder (D:\ant)
3. Set ANT_HOME and Path in environmental variable.



4. Verify ANT. Open Command prompt and type in ant -version...shows you version of ANT.



Using ANT from Eclipse:

Download Sample ANT Selenium and TestNG 

project From Here..ANT-Selenium-TestNG


Folder Structure of Project Looks like this:



If you want to run ant from command prompt then use brlow command

1. Navigate to project directory
2. use command  --- ant run.

Below is build.xml file.




<project name="Experiment_Ant" basedir=".">

 <!-- Defining property -->

 <property name="project.dir" value="${basedir}" />
 <property name="build.dir" value="${basedir}/build" />
 <property name="jar.dir" value="${basedir}/lib" />
 <property name="src.dir" value="${basedir}/src" />
 <property name="ng.result" value="test-output" />

 <!-- Setting Classpath for jar files -->
 <target name="setClassPath">
  <path id="classpath_jars">
   <pathelement path="${basedir}/" />
   <fileset dir="${jar.dir}">
    <include name="*.jar" />
   </fileset>
  </path>
  <pathconvert pathsep=":" property="test.classpath" refid="classpath_jars" />
 </target>
 <!-- Loading Testng -->
 <target name="loadTestNG" depends="setClassPath">
  <taskdef resource="testngtasks" classpath="${test.classpath}" />
 </target>
 <!-- Deleting directories -->
 <target name="clean">
  <echo message="deleting existing build directory " />
  <delete dir="${build.dir}" />
 </target>
 <!-- Creating build folder to store compiled classes -->
 <target name="init" depends="clean,setClassPath">
  <mkdir dir="${build.dir}" />
 </target>
 <!-- Compiling java files -->
 <target name="compile" depends="clean,init,setClassPath,loadTestNG">
  <echo message="" />
  <echo message="compiling………." />
  <javac destdir="${build.dir}" srcdir="${src.dir}"
   includeantruntime="false" classpath="${test.classpath}" />
 </target>
 <target name="run" depends="compile">
  <testng classpath="${test.classpath}:${build.dir}">
   <xmlfileset dir="${basedir}" includes="testng.xml" />
  </testng>
 </target>

</project>