java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal

今天用maven編寫Selenium測試程序時,調用html

 

HtmlUnitDriver driver = new HtmlUnitDriver(true);java

 

反法時報錯以下:apache

java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal  
        at java.lang.ClassLoader.defineClass1(Native Method)  
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)  
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)  
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)  
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)  
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)  
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)  
        at java.security.AccessController.doPrivileged(Native Method)  
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)  
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)  
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)  
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)  
        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)api

//=================================dom

 

解決辦法:在pom文件中添加以下內容maven

<dependency>  
        <groupId>xml-apis</groupId>  
        <artifactId>xml-apis</artifactId>  
        <version>1.4.01</version>  
    </dependency>  

 

更新後問題解決。測試

相關文章
相關標籤/搜索