【问题标题】:Unable to run selenium web-driver scripts through build.xml using ANT无法使用 ANT 通过 build.xml 运行 selenium web-driver 脚本
【发布时间】:2014-10-13 12:18:09
【问题描述】:

在使用命令提示符/hudson 工具执行 build.xml 文件时出现此错误“错误:包 jxl 不存在”

我正在使用 Testng+ant 来运行我现有的在混合+页面工厂框架中开发的 selenium webdriver 脚本

当我在单个类中(即在功能驱动的框架中)有脚本时,我能够生成 testngXSLT 报告。

下面是我的 Build.xml 文件。

<?xml version ="1.0" encoding="iso-8859-1"?>

<project name="BulkInvite" default="usage" basedir=".">
    <!-- ========== Initialize Properties =================================== -->
        <property environment="env"/>    
        <property name="ws.home" value="${basedir}"/>
        <property name="ws.jars" value="D:\jar-files"/>
        <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="setClassPath" unless="test.classpath">
            <path id="classpath_jars">
                <fileset dir="${ws.jars}" includes="*.jar"/>
            </path>
            <pathconvert pathsep=":" 
                property="test.classpath" 
                refid="classpath_jars"/>
        </target>
     <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 -->
         <!-- 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.5" 
                    source="1.5"
                    includeantruntime="true"
                    classpath="${test.classpath}"
                >
                </javac>

              </target>


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

        <!-- run -->
        <target name="run" depends="compile">
            <testng classpath="${test.classpath}:${test.dest}" suitename="Bulkinvite_Suite">    
                <xmlfileset dir="test-output" includes="BulkinviteExecute.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="generateReport" >
        <mkdir dir="${ws.home}/XSLT_Reports/output">
        </mkdir>

        <xslt in="${ng.result}/testng-results.xml" style="src/xslt/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>

    <!--using javax mailjar and javax activation jar trying to send report as zip file  -->

    <target name="sendMail" depends="generateReport">           


    <zip destfile="${ws.home}/XSLT_Reports/output.zip" basedir="${ws.home}/XSLT_Reports/output"/>

    <mail
    tolist="abc.adsf@asdf.com"
    from="XXX@gmail.com"
    subject="ANT_AUTO_Generated_EMAIL__Hurraih.."
    mailhost="smtp.gmail.com"
    mailport="XXX"
    ssl="true"
    user="XXXXX@gmail.com"
    password="XXXX">
    <attachments>
    <fileset dir="${ws.home}/XSLT_Reports/">
    <include name="**/*.zip"/>
    </fileset>
    </attachments>

    </mail>
    </target>
    </project> 

无法找出错误,请帮助我找出解决方案...

【问题讨论】:

    标签: java xml xslt ant selenium-webdriver


    【解决方案1】:

    根据xml中的指定位置检查是否有jxl和jExcel。 IE。 D:\jar 文件

    【讨论】:

    • 感谢回复我已经检查过了,我在指定位置有jar文件。
    • 我已经修复了 package jxl not found 的问题,但是我在另一个项目中有一个 pagefactory 类,该类正在这个类中使用。请让我知道我在哪里包含该项目和要在构建 .xm 文件中调用的特定类
    • 各位有什么帮助,我google了很多,但没有找到解决方案
    【解决方案2】:

    问题已解决:我将 jxl.jar 文件放在 D 驱动器的一个文件夹中,该文件夹也名为 jxl.jar,因此我已将 jar 文件移出该文件夹并删除该文件夹,现在它正在工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多