Tag Archives: TestNG Frame Warning

How to Solve TestNG Frame Warning:Cannot find class in classpath: NewTest

When TestNG of selenium + java runs, the following error is reported:

org.testng.TestNGException: 
Cannot find class in classpath: NewTest
	at org.testng.xml.XmlClass.loadClass(XmlClass.java:81)
	at org.testng.xml.XmlClass.init(XmlClass.java:73)
	at org.testng.xml.XmlClass.<init>(XmlClass.java:59)
	at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:543)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at javax.xml.parsers.SAXParser.parse(Unknown Source)
	at javax.xml.parsers.SAXParser.parse(Unknown Source)
	at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:17)
	at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:10)
	at org.testng.xml.Parser.parse(Parser.java:172)
	at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:311)
	at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88)
	at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
	at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

Found a lot of information on the Internet, changed the XML file, but still can’t

original XML file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="none">
  <test name="Test">
  </test> <!-- Test -->
</suite> <!-- Suite -->

Modified xml files

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="true">
  <test name="Test">
  	<classes>
  		<class name="com.frame.ng.Newtest"/>
  	</classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

Later, I saw a friend in Zhihu saying that the source folder path had been wrongly written when the testngclass was newly built. So changed the path, everything cleared up after rain