1
votes

I am trying to run a testng xml file in a suite.But when i run file
as run as testng suite i am getting below error in console

org.testng.TestNGException: org.xml.sax.SAXParseException; lineNumber: 37; columnNumber: 9; The content of element type "suite" must match "(groups?,(listeners|packages|test|parameter|method-selectors|suite-files)*)".
at org.testng.TestNG.parseSuite(TestNG.java:327)
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)

Caused by: org.xml.sax.SAXParseException; lineNumber: 37; columnNumber: 9; The content of element type "suite" must match "(groups?,(listeners|packages|test|parameter|method-selectors|suite-files)*)". at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284) at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:1994) at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:879) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1783) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2970) 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:118) 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:643) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327) 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) ... 6 more

Since i am new to automation testing i am not able to find out why is the issue arises.I checked with all syntax error and i feel that it
is correct.But i am not able to solve this issue.This is my xml file which i am trying to run but getting error

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
    <suite name="Merck Production Smoke Test Automation Test Suite">
    <parameter name="appURL" value="https://webqws.sial.com"/>
    <parameter name="browserType" value="chrome"/>   
    <listeners>
    <listener class-name="customListener.TestNGCustomReportListener"> 
    </listener>
    <listener class-name="customListener.Customreporter"/>
    </listeners>
    <!--  --> <test name="Merck Production Suite - Automation Scripts 
    Execution - US">
    <parameter name="countryName" value="United States"/>      
    <classes>
    <class name="testScript.Merck_Web_eCommerce_SmokeTest"/>   
    </classes>    
    </test> -->    
    <test name="Merck Production Suite - Automation Scripts Execution - UK">    
    <parameter name="countryName" value="United Kingdom"/>    
    <classes>    
    <class name="testScript.Merck_Web_eCommerce_SmokeTest"/>    
    </classes>     
    </test>    
    <!-- <test name="Merck Production Suite - Automation Scripts Execution - 
   INDIA">
   <parameter name="countryName" value="India"/>   
   <classes>
   <class name="testScript.Merck_Web_eCommerce_SmokeTest"/>
   </classes>   
   </test>  -->    
   </suite>
1
Add your xml file to the questionAlexey R.
Welcome to Stack Overflow! Can you validate your test xml file (in eclipse, ...)? (When you pasted it literally),I am suspicious about the unmatched closing --> (after first closing </test>)xerx593
Ok..let me checkpinki talukdar
Thank you for your response.I have validate the XML file in eclipse and i got error like "The markup declarations contained or pointed to by the document type declaration must be well formed" I am not getting still for which line i am getting this errorpinki talukdar

1 Answers

0
votes

(most probable) Problem reasons:

  1. Unmatched closing --> in your xml file.

    Solution: Delete it.

  2. (After fixing 1., I still had:) "invalid DTD"(!), like here.

    Solution: Use https!;) (in <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" >)