gpt4 book ai didi

java - org.testng.TestNGException : An error occurred while instantiating class

转载 作者:行者123 更新时间:2023-12-02 09:57:38 30 4
gpt4 key购买 nike

我使用 TestNG 的 selenium 自动化框架在 Windows 7 上运行良好,但是当我在 Windows 10 上配置相同的框架时,我面临以下问题。您能帮我解决同样的问题吗?

测试详细信息:

操作系统: Windows 10 64 位

Eclipse 版本:版本:2019-03 (4.11.0)

TestNG版本:6.14.3

[RemoteTestNG] detected TestNG version 6.14.3 org.testng.TestNGException: An error occurred while instantiating class com.saf.aw_nxt_end_to_end_tests.AW_NXT_Login: org/w3c/dom/ElementTraversal at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:435) at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:336) at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:125) at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:190) at org.testng.internal.TestNGClassFinder.processFactory(TestNGClassFinder.java:203) at org.testng.internal.TestNGClassFinder.processMethod(TestNGClassFinder.java:179) at org.testng.internal.TestNGClassFinder.processClass(TestNGClassFinder.java:171) at org.testng.internal.TestNGClassFinder.(TestNGClassFinder.java:121) at org.testng.TestRunner.initMethods(TestRunner.java:370) at org.testng.TestRunner.init(TestRunner.java:271) at org.testng.TestRunner.init(TestRunner.java:241) at org.testng.TestRunner.(TestRunner.java:192) at org.testng.remote.support.RemoteTestNG6_12$1.newTestRunner(RemoteTestNG6_12.java:33) at org.testng.remote.support.RemoteTestNG6_12$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG6_12.java:66) at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:713) at org.testng.SuiteRunner.init(SuiteRunner.java:260) at org.testng.SuiteRunner.(SuiteRunner.java:198) at org.testng.TestNG.createSuiteRunner(TestNG.java:1295) at org.testng.TestNG.createSuiteRunners(TestNG.java:1273) at org.testng.TestNG.runSuitesLocally(TestNG.java:1128) at org.testng.TestNG.runSuites(TestNG.java:1049) at org.testng.TestNG.run(TestNG.java:1017) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77) Caused by: java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) at java.net.URLClassLoader.access$100(URLClassLoader.java:74) at java.net.URLClassLoader$1.run(URLClassLoader.java:369) at java.net.URLClassLoader$1.run(URLClassLoader.java:363) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:362) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.apache.xerces.parsers.AbstractDOMParser.startDocument(Unknown Source) at org.apache.xerces.impl.dtd.XMLDTDValidator.startDocument(Unknown Source) at org.apache.xerces.impl.XMLDocumentScannerImpl.startEntity(Unknown Source) at org.apache.xerces.impl.XMLVersionDetector.startDocumentParsing(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.DOMParser.parse(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:205) at org.apache.log4j.xml.DOMConfigurator$1.parse(DOMConfigurator.java:749) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:871) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:755) at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:896) at com.saf.utilities.Log.getInstance(Log.java:19) at com.saf.base.BaseTest.(BaseTest.java:138) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:24) at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:423) ... 24 more Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 58 more Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:"C:\Program Files (x86)\HP\Unified Functional Testing\bin\java_shared\classes";"C:\Program Files (x86)\HP\Unified Functional Testing\bin\java_shared\classes\jasmine.jar"

最佳答案

看起来您收到了 java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal 错误。

来自Another Answer:
出现此错误的原因是 1.4.01 版本的 xml-apis 库包含所需的 ElementTraversal 类。其他版本如2.0.0、1.0.0等不包含它,应用程序在编译时失败。

  • MAVEN 解决方案:

在 pom.xml 中,将“xml-apis”依赖项设置为版本 1.4.01:

<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
  • 其他人的解决方案:

如果不使用maven,您可以手动添加xml-apis库,版本1.4.01。您将在 xml-commons 二进制包中找到这些 jar,名为“XML CommonsExternal 1.4.01”,您可以在此处下载:http://xerces.apache.org/mirrors.cgi

最后,使用此版本的库编译并执行您的 java 应用程序/项目。

关于java - org.testng.TestNGException : An error occurred while instantiating class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55877440/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com