项目如下:
在eclipse中运行** TestngTestSuiteUsingXML ** java文件时,它正在获取 Test.XML ,它运行正常。
但是当我在命令中验证相同时,提示错误如下:
C:\Jars>javac TestngTestSuiteUsingXML.java
TestngTestSuiteUsingXML.java:6: error: package org.testng does not exist
import org.testng.TestNG;
^
TestngTestSuiteUsingXML.java:7: error: package org.testng.xml does not exist
import org.testng.xml.XmlSuite;
^
TestngTestSuiteUsingXML.java:15: error: cannot find symbol
XmlSuite suite = new XmlSuite();
^
symbol: class XmlSuite
location: class TestngTestSuiteUsingXML
TestngTestSuiteUsingXML.java:15: error: cannot find symbol
XmlSuite suite = new XmlSuite();
^
symbol: class XmlSuite
location: class TestngTestSuiteUsingXML
TestngTestSuiteUsingXML.java:17: error: cannot find symbol
List<XmlSuite> suites = new ArrayList<XmlSuite>();
^
symbol: class XmlSuite
location: class TestngTestSuiteUsingXML
TestngTestSuiteUsingXML.java:17: error: cannot find symbol
List<XmlSuite> suites = new ArrayList<XmlSuite>();
^
symbol: class XmlSuite
location: class TestngTestSuiteUsingXML
TestngTestSuiteUsingXML.java:19: error: cannot find symbol
TestNG tng = new TestNG();
^
symbol: class TestNG
location: class TestngTestSuiteUsingXML
TestngTestSuiteUsingXML.java:19: error: cannot find symbol
TestNG tng = new TestNG();
^
symbol: class TestNG
location: class TestngTestSuiteUsingXML
8 errors
答案 0 :(得分:1)
您必须将testNG.jar添加到类路径中。以下链接可能会有所帮助: -
Java command line with external .jar
How to include jar files with java file and compile in command prompt
你必须下载testNG jar并将它和selenium jar文件一起添加到你的类路径中。 我建议你使用构建和依赖工具,如maven或ant