TestNG 参数在值中声明变量问题
Posted
技术标签:
【中文标题】TestNG 参数在值中声明变量问题【英文标题】:TestNG parameters declare variable issue in value 【发布时间】:2020-07-31 22:42:25 【问题描述】:我在为我的 testing.xml 传递这个值时遇到问题,主要是因为元素在行之间包含“”,这是我下面粘贴在 xml 中的代码和我在 xml 文件中声明的参数语句
//*[@id=\"aaa_registered_check-false\"]
有什么帮助吗?对 testng 来说还是很新的......谢谢!
代码错误
[RemoteTestNG] detected TestNG version 6.14.3
org.testng.TestNGException: org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 43; Element type "parameter" must be followed by either attribute specifications, ">" or "/>".
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:98)
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: 6; columnNumber: 43; Element type "parameter" must be followed by either attribute specifications, ">" or "/>".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at java.xml/javax.xml.parsers.SAXParser.parse(SAXParser.java:197)
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
【问题讨论】:
【参考方案1】:如果问题仅与 "
有关,请尝试更改 '
【讨论】:
以上是关于TestNG 参数在值中声明变量问题的主要内容,如果未能解决你的问题,请参考以下文章
在值中搜索字符串并在 VB.NET 中的 LINQ to XML 中获取属性值