2

When I followed this link LINK to generate XSLT Report Using testng and to send email reports getting error message (Ex: package org.openqa.seleni um does not exist, etc...0).

Please suggest me.

build.xml code is:

<project name="XSLT" default="sendMail" 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">
    <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>

    <!--  adding XSLT report target to produce XSLT report -->
    <target name="makexsltreports" depends="run">
    <delete dir="${project.dir}/XSLT_Reports/output">
    </delete>
    <mkdir dir="${project.dir}/XSLT_Reports/output"/>
    <xslt in="${ng.result}/testng-results.xml" style="/MFW/XSLT/testng-results.xsl" out="${project.dir}/XSLT_Reports/output/index.html" classpathref="classpath_jars" processor="SaxonLiaison">
    <param name="testNgXslt.outputDir" expression="${project.dir}/XSLT_Reports/output/"/><param name="testNgXslt.showRuntimeTotals" expression="true"/>
    <param expression="true" name="testNgXslt.sortTestCaseLinks" />
    <param expression="FAIL,SKIP,PASS,CONF,BY_CLASS" name="testNgXslt.testDetailsFilter" />
    </xslt>
    </target>

    <!--  using javax.mail.jar and javax.activation.jar trying to send report as zip file -->
    <target name="sendMail" depends="makexsltreports">
    <zip destfile="${project.dir}/XSLT_Reports/output.zip" basedir="${project.dir}/XSLT_Reports/output" />
    <mail
    tolist="qa@gmail.com"
    from="test@gmail.com"
    subject="Email subject"
    mailhost="smtp.gmail.com"
    mailport="465"
    ssl = "true"
    user="abc@gmail.com"
    password="123456">
    <attachments>
    <fileset dir="${project.dir}/XSLT_Reports/">
    <include name="**/*.zip"/>
    </fileset>
    </attachments>
    </mail>
    </target>
    </project>

Error:

D:\MFW\XSLT>ant makexsltreports
Buildfile: D:\MFW\XSLT\build.xml

clean:
     [echo] deleting existing build directory
   [delete] Deleting directory D:\MFW\XSLT\build

setClassPath:

init:
    [mkdir] Created dir: D:\MFW\XSLT\build

compile:
     [echo]
     [echo] compilingààà.
    [javac] Compiling 1 source file to D:\MFW\XSLT\build
    [javac] D:\MFW\XSLT\src\spk\Testing.java:3: error: package org.openqa.seleni
um does not exist
    [javac] import org.openqa.selenium.WebDriver;
    [javac]                           ^
    [javac] D:\MFW\XSLT\src\spk\Testing.java:4: error: package org.openqa.seleni
um.firefox does not exist
    [javac] import org.openqa.selenium.firefox.FirefoxDriver;
    [javac]                                   ^
    [javac] D:\MFW\XSLT\src\spk\Testing.java:5: error: package org.testng.annota
tions does not exist
    [javac] import org.testng.annotations.Test;
    [javac]                              ^
    [javac] D:\MFW\XSLT\src\spk\Testing.java:9: error: cannot find symbol
    [javac]     @Test
    [javac]      ^
    [javac]   symbol:   class Test
    [javac]   location: class Testing
    [javac] D:\MFW\XSLT\src\spk\Testing.java:11: error: cannot find symbol
    [javac]             WebDriver d = new FirefoxDriver();
    [javac]             ^
    [javac]   symbol:   class WebDriver
    [javac]   location: class Testing
    [javac] D:\MFW\XSLT\src\spk\Testing.java:11: error: cannot find symbol
    [javac]             WebDriver d = new FirefoxDriver();
    [javac]                               ^
    [javac]   symbol:   class FirefoxDriver
    [javac]   location: class Testing
    [javac] 6 errors

BUILD FAILED
D:\MFW\XSLT\build.xml:47: Compile failed; see the compiler error output for deta
ils.

Total time: 1 second

Folder Structure:

Folder Structure

Code:

package spk;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class Testing {
    @Test
    public void test() {
        WebDriver driver = new FirefoxDriver();
        driver.get("http://google.co.in");
        driver.quit();
    }
}
2

Please use below xml file and from command prompt go to project location and run as "ant generateReport" (Should have ANT). Let me know if you have any questions.

.xml file:

<project name="TestAutomation" basedir=".">
    <property name="LIB" value="${basedir}/lib" />
    <property name="BIN" value="${basedir}/bin" />
    <path id="master-classpath">
        <pathelement location="${BIN}" />
        <fileset dir="${LIB}" includes="*.jar"/>
    </path>
    <target name="generateReport">
        <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>
1

Selenium standalone jar and testNg jars are missing . So just keep these jars in you Lib folder and this will resolve your problem.

Since in build.xml you have provided jar location to lib folder. So please keep all your jar files in lib folder and this will start working without showing any error.

Good Luck

  • Abodeqa is this something that can be mavenized? – corsiKa Apr 17 '15 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.