我是ANT build新手,在编译ANT build时遇到错误“package org.testng.annotations不存在”和“package org.openqa.selenium不存在”。xml。
这里是build.xml
<project name="TestNGProject" default="usage" basedir=".">
<!-- ===============Initialize property============================ -->
<property environment="env"/>
<property name="ws.home" value="${basedir}"/
<property name="ws.jars" value="C:\Users\Documents\selenium-2.35.0\AllJars"/>
<property name="test.dest" value="${ws.home}/build"/>
<property name="test.src" value="${ws.home}/src"/>
<property name="ng.results" 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-->
<target name="compile" depends="init, clean">
<delete includeemptydirs="true" quiet="true">
<fileset dir="${test.dest}" includes="**/*"/>
</delete>
<echo message= "making dir..."/>
<mkdir dir="${test.dest}"/>
<echo message="classpath---------: ${test.classpath}"/>
<echo message="compiling..."/>
<javac
includeantruntime="false"
destdir="${test.dest}"
srcdir="${test.src}"
classpath="${test.classpath}"
>
</javac>
</target>
<!--build-->
<target name="build" depends ="init">
</target>
<target name="run" depends ="compile">
<testng classpath="${test.classpath}:${test.dest}" suitename="suite">
<xmlfileset dir ="${ws.home}" includes="testng.xml"/>
</testng>
</target>
<target name="usage">
<echo>
ant run will execute test case
</echo>
</target>
<path id="test.c">
<fileset dir="${ws.jars}" includes="*.jar"/>
</path>
</project>
下面是错误列表
[javac] Compiling 2 source files to C:\Users\workspace\TestNGProject\build
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:3: error: package org.testng.annotations does not exist
[javac] import org.testng.annotations.Test;
[javac] ^
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:4: error: package org.testng.annotations does not exist
[javac] import org.testng.annotations.DataProvider;
[javac] ^
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:5: error: package org.testng.annotations does not exist
[javac] import org.testng.annotations.BeforeClass;
[javac] ^
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:6: error: package org.testng.annotations does not exist
[javac] import org.testng.annotations.AfterClass;
[javac] ^
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:7: error: package org.testng does not exist
[javac] import static org.testng.AssertJUnit.assertEquals;
[javac] ^
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:7: error: static import only from classes and interfaces
[javac] import static org.testng.AssertJUnit.assertEquals;
[javac] ^
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:9: error: package org.openqa.selenium does not exist
[javac] import org.openqa.selenium.By;
[javac] ^
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:10: error: package org.openqa.selenium does not exist
[javac] import org.openqa.selenium.WebDriver;
[javac] ^
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:11: error: package org.openqa.selenium does not exist
[javac] import org.openqa.selenium.WebElement;
[javac] ^
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:12: error: package org.openqa.selenium.firefox does not exist
[javac] import org.openqa.selenium.firefox.FirefoxDriver;
[javac] ^
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:16: error: cannot find symbol
[javac] private WebDriver driver;
[javac] ^
[javac] symbol: class WebDriver
[javac] location: class NewTestNG
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:17: error: cannot find symbol
[javac] private WebElement FahrenheitInput;
[javac] ^
[javac] symbol: class WebElement
[javac] location: class NewTestNG
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:18: error: cannot find symbol
[javac] private WebElement CelsiusInput;
[javac] ^
[javac] symbol: class WebElement
[javac] location: class NewTestNG
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:19: error: cannot find symbol
[javac] private WebElement ConvertButton;
[javac] ^
[javac] symbol: class WebElement
[javac] location: class NewTestNG
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\sample.java
:3: error: package org.testng.annotations does not exist
[javac] import org.testng.annotations.Test;
[javac] ^
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:20: error: cannot find symbol
[javac] @BeforeClass
[javac] ^
[javac] symbol: class BeforeClass
[javac] location: class NewTestNG
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:29: error: cannot find symbol
[javac] @DataProvider(name = "CelsToFahrDP")
[javac] ^
[javac] symbol: class DataProvider
[javac] location: class NewTestNG
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:33: error: cannot find symbol
[javac] @Test(dataProvider = "CelsToFahrDP")
[javac] ^
[javac] symbol: class Test
[javac] location: class NewTestNG
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:40: error: cannot find symbol
[javac] @AfterClass
[javac] ^
[javac] symbol: class AfterClass
[javac] location: class NewTestNG
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\sample.java
:6: error: cannot find symbol
[javac] @Test
[javac] ^
[javac] symbol: class Test
[javac] location: class sample
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:22: error: cannot find symbol
[javac] driver = new FirefoxDriver();
[javac] ^
[javac] symbol: class FirefoxDriver
[javac] location: class NewTestNG
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:25: error: cannot find symbol
[javac] CelsiusInput = driver.findElement(By.xpath("//form[2]/cente
r[2]/input"));
[javac] ^
[javac] symbol: variable By
[javac] location: class NewTestNG
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:26: error: cannot find symbol
[javac] FahrenheitInput = driver.findElement(By.xpath("//form[2]/ce
nter[2]/input[2]"));
[javac] ^
[javac] symbol: variable By
[javac] location: class NewTestNG
[javac] C:\Users\workspace\TestNGProject\src\TestNGPackage\NewTestNG.j
ava:27: error: cannot find symbol
[javac] ConvertButton = driver.findElement(By.xpath("//form[2]/cent
er[2]/input[3]"));
[javac] ^
[javac] symbol: variable By
[javac] location: class NewTestNG
[javac] 24 errors
我还设置了JAVA\u HOME C:\Program Files\JAVA\jdk1.7.0\u 25\bin和ANT\u HOME C:\Users\Documents\selenium-2.35.0\apache-ANT-1.9.2
有人能告诉我如何改掉这个错误吗?
我相信问题就在这里:
<pathconvert pathsep="."
property="test.classpath"
refid="classpath_jars"/>
我不知道"."
是有效路径分隔符的任何环境。结果是${test.classpath}
不是有效路径。这就是编译器无法访问您的TestNG和Selenium类的原因。
您不妨进行测试。classpath与classpath\u jars相同。
(如果XML正确缩进,我会很快发现这一点。)
问题内容: 我有一个包,其中导入了javax.servlet。和javax.servlet.http。,当我尝试在命令提示符下对其进行编译时,出现错误 软件包javax.servlet不存在 我使用JDK 1.7.0和Tomcat 6.0。 问题答案: 您需要将Tomcat 文件的路径添加到编译时类路径。 Java需要在类路径中查找导入的依赖项。否则,它将默认为上面示例中包含的当前文件夹。的是Wi
我正在尝试向现有的企业项目添加maven支持。这是一个多模块项目,前两个模块的编译和打包没有问题,但我面临编译错误,我试图在多个模块中使用相同的依赖关系。我的结构是: 我支持在Eclipse上打开的项目,它没有显示任何错误。当我从父级运行时,它成功地安装了模块1和模块2,但在模块3上失败,表明,。包裹xxx。yyy和符号XXXYYY位于模块2和3的依赖项上列出的jar中。 由于两个模块都依赖于同一
包javax.servlet不存在 我使用JDK1.7.0和Tomcat6.0。
当我试图通过[mvn clean install-DskipTests]通过控制台构建项目时,我得到了一个错误。我在测试中使用testNG SoftAssert,在测试类中我刚刚添加了一个导入组织。测试NG。断言。但是看起来maven没有看到这个包。控制台出错: 包org.testng.asserts不存在 我的pom。xml看起来像
包规范成功地编译了消息“SPBomPackage Compiled”,但在编译包体时,我有两个错误,它们是“错误(17,6):PL/SQL:忽略语句”和“错误(17,17):PLS-00302:必须声明组件‘ITEM\u ID’”,包规范,包体,我使用的三个表格,这个软件包将使用,粘贴和格式很好,您可以在这个链接查看:
我在Eclipse上创建了一个Maven项目,并在pom.xml文件上添加了以下依赖项: 然后,我使用以下代码检查依赖项是否可以编译: 虽然Eclipse不显示任何错误,但当我使用以下命令编译它时: 我收到以下三个错误: 请记住,依赖项对应的JAR文件安装在计算机上的maven存储库中