How to fix : org. testng. TestNGException: Cannot find class in classpath in Selenium?

Sometimes, we get an exception: 

org.testng.TestNGException: Cannot find class in classpath in Selenium, something like:

Cannot find class in classpath: <CLASSNAME>.java
    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:539)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)

Solution: Check the path & classname in testng.xml file and correct the classname if typed incorrectly. Also re-validate the path of the class mentioned from root of the project that we plan to invoke using our testng.xml file.

org.testng.TestNGException: Cannot find class in classpath

Post a Comment

0 Comments