org.testng.TestNGException: Cannot find class in classpath: com.facebook.qa.testcases.LoginPageTest



  • [RemoteTestNG] detected TestNG version 6.14.2
    org.testng.TestNGException: 
    Cannot find class in classpath: com.facebook.qa.testcases.LoginPageTest
        at org.testng.xml.XmlClass.loadClass(XmlClass.java:77)
        at org.testng.xml.XmlClass.init(XmlClass.java:69)
        at org.testng.xml.XmlClass.<init>(XmlClass.java:55)
        at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:575)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
        at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
        at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:766)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:356)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2786)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:333)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
        at org.testng.xml.XMLParser.parse(XMLParser.java:38)
        at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:16)
        at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:9)
        at org.testng.xml.Parser.parse(Parser.java:152)
        at org.testng.xml.Parser.parse(Parser.java:233)
        at org.testng.TestNG.parseSuite(TestNG.java:295)
        at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:348)
        at org.testng.TestNG.initializeEverything(TestNG.java:995)
        at org.testng.remote.support.RemoteTestNG6_12.initialize(RemoteTestNG6_12.java:22)
        at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:97)
        at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
    

    Hi guys,

    Can anyone help me to solve above TestNG exception?

    ANSWER : I saw that this message was closed without answer. I had same issue and spent hours trying all available online solutions. Finally, I figured out myself that I had placed TestRunner (Driver script) in main package instead of test package of maven project. Once I moved it to test package, it worked like a charm ! Hope this helps to others.



  • Clean your project and re-run again. Project->clean

    or else

    In testNG.xml ->configure as

    <class name="Packagename.Classname"/>
    

    . This issue will be fixed.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2