Hi All,

         I am using testng. while executing the class file in testng I am
getting the below error and here my sample
code where exactly i made mistake please help me on this...


below is the error:
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.(TestNGContentHandler.java:539)
     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 com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.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:1)
     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)

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Hiral Legend at Nov 28, 2012 at 5:00 pm
    Hi All,

             I am using testng. while executing the class file in testng I am
    getting the below error and here my sample
    code where exactly i made mistake please help me on this...


    import org.testng.annotations.Test;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.AfterTest;

    public class NewTest {
       @Test
       public void f() {
           System.Out.println("this is method");
       }
       @BeforeTest
       public void beforeTest() {
           System.Out.println("this is before method");
       }

       @AfterTest
       public void afterTest() {
           System.Out.println("this is after method");
       }

    }


    below is the error:
    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.(TestNGContentHandler.java:539)
         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 com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.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:1)
         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)

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jyothi k at Nov 29, 2012 at 4:49 am
    Hi Hiral,

    There are no errors in code. I think you are not included your NewTest
    class into build path.
    Go to Project Explorer -> src -> now place this NewTest class file and then
    run it...I think now it will run.
    Let me know if any issues.

    Regards,
    Jyothi
    On Wed, Nov 28, 2012 at 10:30 PM, Hiral Legend wrote:

    Hi All,

    I am using testng. while executing the class file in testng I am
    getting the below error and here my sample
    code where exactly i made mistake please help me on this...


    import org.testng.annotations.Test;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.AfterTest;

    public class NewTest {
    @Test
    public void f() {
    System.Out.println("this is method");
    }
    @BeforeTest
    public void beforeTest() {
    System.Out.println("this is before method");
    }

    @AfterTest
    public void afterTest() {
    System.Out.println("this is after method");

    }

    }


    below is the error:
    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:539)
    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 com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.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:1)
    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)

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Kiran_sahoo at Nov 29, 2012 at 5:06 am
    Hi,

    Can you post the testng xml file ?

    Regards,
    Kiran
    On Wednesday, 28 November 2012 22:30:45 UTC+5:30, Hiral wrote:

    Hi All,

    I am using testng. while executing the class file in testng I am
    getting the below error and here my sample
    code where exactly i made mistake please help me on this...


    import org.testng.annotations.Test;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.AfterTest;

    public class NewTest {
    @Test
    public void f() {
    System.Out.println("this is method");
    }
    @BeforeTest
    public void beforeTest() {
    System.Out.println("this is before method");
    }

    @AfterTest
    public void afterTest() {
    System.Out.println("this is after method");
    }

    }


    below is the error:
    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:539)
    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 com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.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:1)
    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)
    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/xgYnkGdD2ssJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Murali at Nov 29, 2012 at 6:07 am
    Hi Hiral,

    once check testNG file

    <classes><class name="packageName.testcaseName"></class>

    .....

    On Wednesday, November 28, 2012 10:06:48 PM UTC+5:30, Hiral wrote:

    Hi All,

    I am using testng. while executing the class file in testng I am
    getting the below error and here my sample
    code where exactly i made mistake please help me on this...


    below is the error:
    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:539)
    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 com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.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:1)
    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)
    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/v7pkFJoXnM8J.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Afzal at Apr 23, 2014 at 7:51 pm
    Hi

    This is might be very late response. but, recently i faced same issue.....

    Solution for this is

    When your Trying to run Testng.xml . you should put packagename.class

    for example

    <class name="com.test.format1.firstTest"/>
    On Wednesday, November 28, 2012 10:06:48 PM UTC+5:30, Hiral Legend wrote:

    Hi All,

    I am using testng. while executing the class file in testng I am
    getting the below error and here my sample
    code where exactly i made mistake please help me on this...


    below is the error:
    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:539)
    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 com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.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:1)
    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)
    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fcd75ff7-6991-41ef-8ad9-a92c49596516%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupselenium-users @
categoriesselenium
postedNov 28, '12 at 4:36p
activeApr 23, '14 at 7:51p
posts6
users5
websiteseleniumhq.org

People

Translate

site design / logo © 2022 Grokbase