Ant compile is showing "Package does not exist" for BaseTest | Selenium Forum
M
Posted on 09/10/2016
Sir,

Source code of the project shared at Google Drive: https://drive.google.com/drive/folders/0B4d06fKEIwIsbHZ4bXRMNlFlczQ



I am trying to execute the Zoho Project through Ant.But when i am giving
ant compile , in command prompt i am getting error such as

C:\Users\kalyan\Desktop\DataDrivenFrameworkZoho1\src\test\java\com\zoho\ddframework\base\BaseTest.java:13 : error :import org.apache.commons.io
"Package Does not exist"


C:\Users\kalyan\Desktop\DataDrivenFrameworkZoho1\src\test\java\com\zoho\ddframework\base\BaseTest.java:13 : error :import import org.openqa.selenium.By
"Package Does not exist"

It is showing the error message for the packages in the BaseTest

These are the following some packages that is imported in BaseTest

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

Please find below build.xml file that i am using in the project

==================

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE project [
]>

<project name="Learning TestNG" default="usage" basedir=".">

<!-- ========== Initialize Properties =================================== -->
<property environment="env"/>

<property name="ws.home" value="${basedir}"/>
<property name="ws.jars" value="D:/AntJars"/>
<property name="test.dest" value="${ws.home}/build"/>
<property name="test.src" value="${ws.home}/src"/>
<property name="ng.result" value="test-output"/>

<!--target name="start-selenium-server">
<java jar="${ws.home}/lib/selenium-server.jar"/>
</target-->

<target name="setClassPath" unless="test.classpath">
<path id="classpath_jars">
<fileset dir="${ws.jars}" includes="*.jar"/>
</path>
<pathconvert pathsep=":"
property="test.classpath"
refid="classpath_jars"/>
</target>

<path id="testcase.path">


<pathelement location="${test.dest}"/>

<fileset dir="${ws.jars}">
<include name="*.jar"/>
</fileset>

</path>

<target name="init" depends="setClassPath">
<tstamp>
<format property="start.time" pattern="MM/dd/yyyy hh:mm aa" />
</tstamp>
<condition property="ANT"
value="${env.ANT_HOME}/bin/ant.bat"
else="${env.ANT_HOME}/bin/ant">
<os family="windows" />
</condition>
<taskdef name="testng" classpath="${test.classpath}"
classname="org.testng.TestNGAntTask" />

</target>

<!-- all -->
<target name="all">
</target>

<!-- clean -->
<target name="clean">
<delete dir="${test.dest}"/>
</target>

<!-- compile -->
<target name="compile" depends="init, clean" >
<delete includeemptydirs="true" quiet="true">
<fileset dir="${test.dest}" includes="**/*"/>
</delete>
<echo message="making directory..."/>
<mkdir dir="${test.dest}"/>
<echo message="classpath------: ${test.classpath}"/>
<echo message="compiling..."/>
<javac
debug="true"
destdir="${test.dest}"
srcdir="${test.src}"
target="1.8"
classpath="${test.classpath}"
includeantruntime="false"
>
</javac>
</target>

<!-- build -->
<target name="build" depends="init">
</target>

<!-- run -->
<target name="run" depends="compile">
<testng classpath="${test.classpath}:${test.dest}" suitename="suite1">
<xmlfileset dir="${ws.home}" includes="src/test/resources/testng.xml"/>
</testng>
<!--
<testng classpath="${test.classpath}:${test.dest}" groups="fast">
<classfileset dir="${test.dest}" includes="example1/*.class"/>
</testng>
-->
</target>

<target name="usage">
<echo>
ant run will execute the test
</echo>
</target>

<path id="test.c">
<fileset dir="${ws.jars}" includes="*.jar"/>
</path>

<target name="makexsltreports">
<mkdir dir="${ws.home}/XSLT_Reports/output"/>

<xslt in="${ng.result}/testng-results.xml" style="src/test/resources/testng-results.xsl"
out="${ws.home}/XSLT_Reports/output/index.html" classpathref="test.c" processor="SaxonLiaison">
<param name="testNgXslt.outputDir" expression="${ws.home}/XSLT_Reports/output/"/>
<param name="testNgXslt.showRuntimeTotals" expression="true"/>
</xslt>
</target>

<target name="report_email" >
<java classname="com.qtpselenium.zoho.project.util.mail.SendMail" classpathref="testcase.path" />
</target>
</project>

=========================

I have added the jars at D:/AntJars


egards,
Anand

M
Replied on 10/10/2016

take a look at this q/a and then download the jar file.

http://stackoverflow.com/questions/21673618/package-org-apache-commons-io-does-not-exist-error