I'm trying to use HtmlUnit in a Kotlin project but I get the following error when I compile:
Error:Kotlin: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class com.gargoylesoftware.htmlunit.html.DomElement, unresolved supertypes: ElementTraversal
This is because ElementTraversal is a java 7 feature. How can I solve this?
The org.w3c.dom.ElementTraversal
is part of xml-apis
which is a dependency of xerces:xercesImpl
. The xerces:xercesImpl
is in turn a dependency of htmlunit
.
Make sure to add the transitive dependencies of htmlunit
to your project.
With gradle all that is needed is:
compile 'net.sourceforge.htmlunit:htmlunit:2.22'