2016-05-16 5 views
0

Ich habe anscheinend einen Konflikt mit Java-Versionen. Kompilierungsfehler sind meist mit Webdriver-Dateien verbunden. Ich verwende derzeit jdk1.8.0_65 und habe es richtig im Pfad konfiguriert. F: \ DataDriven \ WDDF> ant kompilieren Buildfile: F: \ DataDriven \ WDDF \ build.xmlAnt Kompilierfehler, meist mit Webdriver-Dateien.

setPath: 

initialization: 

clear: 

compile: 
[echo] Creating directory... 
[mkdir] Created dir: F:\DataDriven\WDDF\build 
[echo] Suite class path Is ------: F:\DataDriven\WDDF\JarFiles\SaxonLiaison 
.jar:F:\DataDriven\WDDF\JarFiles\commons-codec-1.10.jar:F:\DataDriven\WDDF\JarFi 
les\commons-logging-1.2.jar:F:\DataDriven\WDDF\JarFiles\curvesapi-1.03.jar:F:\Da 
taDriven\WDDF\JarFiles\junit-4.12.jar:F:\DataDriven\WDDF\JarFiles\log4j-1.2.17.j 
ar:F:\DataDriven\WDDF\JarFiles\poi-3.14-20160307.jar:F:\DataDriven\WDDF\JarFiles 
\poi-examples-3.14-20160307.jar:F:\DataDriven\WDDF\JarFiles\poi-excelant-3.14-20 
160307.jar:F:\DataDriven\WDDF\JarFiles\poi-ooxml-3.14-20160307.jar:F:\DataDriven 
\WDDF\JarFiles\poi-ooxml-schemas-3.14-20160307.jar:F:\DataDriven\WDDF\JarFiles\p 
oi-scratchpad-3.14-20160307.jar:F:\DataDriven\WDDF\JarFiles\saxon-8.7.jar:F:\Dat 
aDriven\WDDF\JarFiles\testng-6.9.9.jar:F:\DataDriven\WDDF\JarFiles\testng-xslt-m 
aven-plugin-test-0.0.jar:F:\DataDriven\WDDF\JarFiles\xmlbeans-2.6.0.jar 
[echo] compiling... 
[javac] F:\DataDriven\WDDF\build.xml:60: warning: 'includeantruntime' was 
not set, defaulting to build.sysclasspath=last; set to false for repeatable builds 

[javac] Compiling 9 source files to F:\DataDriven\WDDF\build 
[javac] 
[javac]   WARNING 
[javac] 
[javac] The -source switch defaults to 1.8 in JDK 1.8. 
[javac] If you specify -target 1.5 you now must also specify -source 1.5. 
[javac] Ant will implicitly add -source 1.5 for you. Please change your build file. 
[javac] warning: [options] bootstrap class path not set in conjunction with-source 1.5 
[javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release 
[javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release 
[javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. 
[javac] F:\DataDriven\WDDF\src\com\stta\TestSuiteBase\SuiteBase.java:7: error: package 
org.openqa.selenium does not exist 
[javac] import org.openqa.selenium.WebDriver; 
[javac]       ^
[javac] F:\DataDriven\WDDF\src\com\stta\TestSuiteBase\SuiteBase.java:8: error: package 
org.openqa.selenium.firefox does not exist 
[javac] import org.openqa.selenium.firefox.FirefoxDriver; 
[javac]         ^
[javac] F:\DataDriven\WDDF\src\com\stta\TestSuiteBase\SuiteBase.java:17: error: cannot find symbol 
[javac]  public static WebDriver driver=null; 
[javac]     ^
[javac] symbol: class WebDriver 
[javac] location: class SuiteBase 
[javac] F:\DataDriven\WDDF\src\com\stta\TestSuiteBase\SuiteBase.java:37: error: cannot find symbol 
[javac]      driver = new FirefoxDriver(); 
[javac]        ^
[javac] symbol: class FirefoxDriver 
[javac] location: class SuiteBase 
[javac] 4 errors 
[javac] 4 warnings 

BUILD FAILED 
F:\DataDriven\WDDF\build.xml:60: Compile failed; see the compiler error output f 
or details. 

Total time: 1 second 

Hier mein build.xml ist

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

<project name="WDDF" default="usage" basedir="."> 

<property environment="appenv"/>  
<property name="project.home" value="${basedir}"/> 
<!-- Set JarFiles Folder's Path. --> 
<property name="project.jars" value="F:\DataDriven\WDDF\JarFiles"/> 
<property name="report.dest" value="${project.home}/build"/> 
<property name="report.src" value="${project.home}/src"/> 
<property name="report.result" value="test-output"/> 

<target name="setPath" unless="suite.classpath"> 
    <path id="jar_path"> 
     <fileset dir="${project.jars}" includes="*.jar"/> 
    </path> 
    <pathconvert pathsep=":" 
     property="suite.classpath" 
     refid="jar_path"/> 
</target> 

<target name="initialization" depends="setPath"> 
    <tstamp> 
     <format property="Init.time" pattern="MM/dd/yyyy hh:mm aa" /> 
    </tstamp> 
    <condition property="ANT" 
     value="${appenv.ANT_HOME}/bin/ant.bat" 
     else="${appenv.ANT_HOME}/bin/ant"> 
       <os family="windows" /> 
    </condition> 
    <taskdef name="testng" classname="org.testng.TestNGAntTask"> 
      <classpath> 
       <pathelement location="F:\DataDriven\WDDF\JarFiles\testng-6.9.9.jar"/> 
      </classpath> 
    </taskdef> 
</target>  

<!-- To clear --> 
<target name="clear"> 
    <delete dir="${report.dest}"/> 
</target> 

<!-- To compile --> 

    <target name="compile" depends="initialization, clear" > 
     <delete includeemptydirs="true" quiet="true"> 
      <fileset dir="${report.dest}" includes="**/*"/> 
     </delete> 
     <echo message="Creating directory..."/> 
     <mkdir dir="${report.dest}"/> 
     <echo message="Suite class path Is ------: ${suite.classpath}"/> 
     <echo message="compiling..."/> 
     <javac 
      debug="true" 
      destdir="${report.dest}" 
      srcdir="${report.src}" 
      target="1.5" 
      classpath="${suite.classpath}" 
     > 
     </javac> 
     <copy todir="${report.dest}"> 
        <fileset dir="${report.src}" excludes="**/*.java"/> 
      </copy> 
     </target> 


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

<!-- run --> 
<target name="run" depends="compile"> 
    <testng classpath="${suite.classpath}:${report.dest}" suitename="suite1"> 
     <xmlfileset dir="${project.home}" includes="testng.xml"/> 
    </testng>  
</target> 

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


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

</path> 

    <target name="reports"> 
     <mkdir dir="${project.home}/XSLT_Reports/Reports"/> 
    <!-- Set testng-results.xsl File's Path. --> 
     <xslt in="${report.result}/testng-results.xml" style="src/com/stta/xslt/testng-results.xsl" 
       out="${project.home}/XSLT_Reports/Reports/index.html" classpathref="test.c" processor="SaxonLiaison"> 
      <param name="testNgXslt.outputDir" expression="${project.home}/XSLT_Reports/Reports/"/> 
      <param name="testNgXslt.showRuntimeTotals" expression="true"/> 
     </xslt> 
    </target> 

</project> 

Antwort

0

Dies könnte darauf zurückzuführen sein, dass Sie eine alte Version von Java verwenden. Es ist Java 5 in dir. Versuchen Sie, die Java-Version 8 im target Parameter in dem unten stehenden Block in Ihrem build.xml zu ändern:

<javac 
    debug="true" 
    destdir="${report.dest}" 
    srcdir="${report.src}" 
    target="1.8" 
    classpath="${suite.classpath}" 
> 

Refresh und reinigen Sie Ihr Projekt danach.