我在cmd:ant makexsltreports执行命令期间遇到此错误

时间:2016-01-31 15:54:01

标签: selenium-webdriver

build.xm:76: Exceute failed: java.io.IOException:
cannot run program "{browser}":CreateProcess error=2,The system can not find the file specified
at java.lang.ProcessBuilder.start<ProcessBuilder.java:1047>
at java.lang.Runtime.exec<Runtime.java:617>
at org.apache.tools.ant.taskdefs.launcher.java13CommandLauncher.exec<Java13CommandLauncher.java:58>  

ant clean
ant compile
ant makesxltreports

执行此cmd后出错 此代码在虚拟机上运行良好

请帮助我 build.xml文件在下面给出

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

    <property name="home.dir" value="${basedir}"/>
    <property name="build.dir" value="${home.dir}/build"/>
    <property name="src.dir" value="${home.dir}/src"/>
    <property name="ng.result" value="test-output"/>
    <property name="lib.dir" value="C:/seleniumjavaclient/framework jars_1"/>
    <property name="index.dir" value = "${basedir}/testng_output/index.html"/>

<!-- setClassPath -->
    <target name="setClassPath">
        <path id="classpath_jars">
            <pathelement path="${basedir}/" />
            <fileset dir="${lib.dir}" includes="*.jar" />
        </path>
        <pathconvert pathsep=":" property="test.classpath" refid="classpath_jars" />
    </target>

<!-- loadTestNG -->
    <target name="loadTestNG" depends="setClassPath">
      <taskdef resource="testngtasks" classpath="${test.classpath}"/>
    </target>

<!-- build -->
    <target name="build">
        <mkdir dir="${build.dir}"/>
        <tstamp>
            <format property="timestamp" pattern="dd-MM-yyyy_(HH-mm-ss)"/>
        </tstamp>
        <property name="build.log.dir" location="${basedir}/buildlogs"/>
        <mkdir dir="${build.log.dir}"/>
        <property name="build.log.filename" value="build_${timestamp}.log"/>
        <record name="${build.log.dir}/${build.log.filename}" loglevel="verbose" append="false"/>
        <echo message="build logged to ${build.log.filename}"/>
    </target>

<!-- Clean -->
    <target name="clean">
        <echo message="deleting existing build directory"/>
        <delete dir="${build.dir}"/>
    </target>

<!-- Compile -->
    <target name="compile" depends="clean,build,setClassPath,loadTestNG">
        <echo message="classpath:${test.classpath}"/>
        <echo message="compiling.........."/>
        <javac destdir="${build.dir}" srcdir="${src.dir}" classpath="${test.classpath}" includeantruntime="false"/>
    </target>

<!-- executeApp -->
    <target name="run" depends="compile">
        <testng classpath="${test.classpath}:${build.dir}">
            <xmlfileset dir="${basedir}" includes="testng.xml"/>
        </testng>
    </target>

<!-- Report --> 
    <target name="report" depends="run">
        <delete dir="${basedir}/testng-xslt"/>
        <mkdir dir="${basedir}/testng-xslt"/>
        <xslt in="${basedir}/test-output/testng-results.xml"
        style="${basedir}/testng-results.xsl" out="${basedir}/testng-xslt/index.html" processor="SaxonLiaison">
            <param expression="${basedir}/testng-xslt/" name="testNgXslt.outputDir"/>
            <param expression="true" name="testNGXslt.sortTestCaseLinks"/>
            <param expression="FAIL,SKIP,PASS,BY_CLASS" name="testNgXslt.testDetailsFilter"/>
            <param expression="true" name="testNgXslt.showRuntimeTotals"/>
            <classpath refid="classpath_jars"/>
        </xslt>
    </target>

<!-- makexsltreports-->
    <target name="makexsltreports" depends="report">
        <exec executable="${browser}" spawn="yes">
       <arg line="${index.dir}" />
      </exec>
     </target>
</project>

1 个答案:

答案 0 :(得分:0)

$ {browser}未在属性名称中指定。

 <property name="browser" location="C:/Program Files/Mozilla Firefox/firefox.exe"/>

谢谢你, 穆拉利