Saturday, August 14, 2010

selenium configurations with build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="IDMAutomation" default="stop-server" basedir=".">
  

    <property name="sourceDir" location="src" />
    <property name="imgsDir" location="imgs" />
    <property name="buildDir" location="bin" />
    <property name="reportDir" location="reports" />
    <property name="libDir" location="lib" />
    <property name="profileDir" location="profiles" />
    <property name="testSuiteLocation" location="testSuite" />
  
  
      
    <path id="master-classpath">
        <fileset dir="${libDir}">
            <include name="*.jar"></include>
        </fileset>
        <pathelement path="${buildDir}"></
pathelement>
    </path>
  
    <taskdef resource="testngtasks" classpath="${libDir}/testng-5.10-jdk15.jar" />
  
    <target name="start-server">      
        <java jar="${libDir}/selenium-server.jar" fork="true" spawn="true" >
            <arg line="-firefoxProfileTemplate ${profileDir} -singleWindow -ensureCleanSession" />
        </java>      
    </target>
  
    <target name="clean" description="Remove the build and report directories">
        <delete dir="${buildDir}" />
        <delete dir="${reportDir}" />
        <delete dir="${imgsDir}" />
      
    </target>
  
    <target name="build" description="Creates a build of the test suite.">
    <echo>"Making directory ${buildDir}"</echo>
    <mkdir dir="${buildDir}" />
    <echo>"Making directory ${reportDir}"</echo>
    <mkdir dir="${reportDir}" />
    <mkdir dir="${imgsDir}" />

    <echo>"Doing build..."</echo>
    <javac destdir="${buildDir}" debug="true" deprecation="false" failonerror="true">
    <src path="${sourceDir}" />
    <classpath refid="master-classpath"></classpath>
    </javac>
    </target>
  
    <target name="doTest" description="Execute TestNG tests">
    <testng classpathref="master-classpath" outputdir="${reportDir}"
    sourcedir="${sourceDir}" workingDir="${buildDir}">
    <!-- Specify suites or scripts to run here -->
    <xmlfileset dir="${testSuiteLocation}" includes="*.xml" />          
    </testng>
    </target>
    <target name="stop-server" depends="clean,build,start-server,doTest">
    <get taskname="selenium-shutdown"
    src="http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer" dest=".result.txt"
    ignoreerrors="true" />
    <echo taskname="selenium-shutdown" message="DGF Errors during shutdown are expected" />
    </target>

</project>

No comments:

Post a Comment