Execute .xml file in testNG

953 views
Skip to first unread message

Panikera

unread,
Aug 22, 2012, 6:36:26 AM8/22/12
to testng...@googlegroups.com
Hi All,

             I am using web driver with TestNG framework But I am unable execute .xml file
 here my script for .xml

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="my sample suite">
<test name="Application Login">
    <classes>
        <class name="test.frameWork"></class>
    </classes>
</test>
</suite>  

While executing above .xml file I am getting below error like:

org.testng.TestNGException:
Cannot find class in classpath: test.frameWork
    at org.testng.xml.XmlClass.loadClass(XmlClass.java:80)
    at org.testng.xml.XmlClass.init(XmlClass.java:72)
    at org.testng.xml.XmlClass.<init>(XmlClass.java:58)
    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.impl.dtd.XMLDTDValidator.startElement(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:10)
    at org.testng.xml.Parser.parse(Parser.java:172)
    at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:310)
    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)

Please let me know... asap

Regards,
Raaj

Krishnan Mahadevan

unread,
Aug 22, 2012, 6:40:50 AM8/22/12
to testng...@googlegroups.com
There can be two reasons as to why you would see this :

1. The actual package definition for your class in question is NOT "test.frameWork".
2. There are compilation errors in your project owing to which there is no .class files being generated in your target folder [or whatever is your build folder called as]


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"





--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/i700uD8xcgAJ.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

Panikera Raj

unread,
Aug 22, 2012, 7:51:19 AM8/22/12
to testng...@googlegroups.com
HI Mahadevan,

        As you said the 2) is .Class file generated in target folder.
but I didn't get you for first one.. Can u elaborate that..

Regards,
Raaj

Krishnan Mahadevan

unread,
Aug 22, 2012, 8:38:04 AM8/22/12
to testng...@googlegroups.com
You have the below in your xml file
<class name="test.frameWork">

Can you please check if your class looks like below ?

package test;

public class frameWork{
...
...
}

Note: Per java conventions, class names always begin with a capital letter.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

nguyenkim thuat

unread,
Aug 22, 2012, 9:11:28 AM8/22/12
to testng...@googlegroups.com

While executing above .xml file I am getting below error like:

org.testng.TestNGException:
Cannot find class in classpath: test.frameWork
    at org.testng.xml.XmlClass.loadClass(XmlClass.java:80)
    at org.testng.xml.XmlClass.init(XmlClass.java:72)
    at org.testng.xml.XmlClass.<init>(XmlClass.java:58
Have you tried to add you file .class to the classpath?
For example, add this line to the environment variables: CLASSPATH
C:\*\*\......\target\test-classes; C:\*\*\......\target\classes 
Hope this help.

Best regards.
Reply all
Reply to author
Forward
0 new messages