Getting error in my Maven project 'NoClassDefFoundError' | Selenium Forum
M
Posted on 13/03/2016
Hi,

When I tried to execute following code under a Maven Project I am getting this error "Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal". Is it come thing to do with the dependencies or jar files download? I have downloaded the version 2.52.0 from my Maven. Please help me to figure this issue. Find the screen attached. Thanks.

package rough;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class sample{

public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://in.rediff.com");
driver.findElement(By.xpath("//*[@id='homewrapper']/div[5]/a[3]/div/u")).click();
}
}

M
Replied on 14/03/2016

it is a very common error.

try this.

http://stackoverflow.com/questions/17777821/maven-dependency-conflict-org-w3c-dom-elementtraversal


M
Replied on 15/03/2016

Hi Ashish,

I have gone through your comments and followed the blog you referred me. Now I am getting different error following is my error.
org.testng.TestNGException:
Cannot find class in classpath: com.selenium.framework.GoogleTest
at org.testng.xml.XmlClass.loadClass(XmlClass.java:81)
at org.testng.xml.XmlClass.init(XmlClass.java:73)
at org.testng.xml.XmlClass.<init>(XmlClass.java:59)
at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:539)

I have gone through few blogs as well. But could not resolve. I can see in my Mavan project/Reference Libraries/ xml-apis-1.0.b2.jar

I have added this dependency. Can you please help me. Thanks.
<!-- xml-apis -->
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>2.0.2</version>
</dependency>
As per your comment on my other query I have added this new class ExtentReporterNG.class
<!-- Extent Reports -->
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.40.1</version>
</dependency>

Updated testng.xml file as well
<listeners>
<listener class-name="com.selenium.framework.ExtentReporterNG" />
</listeners>

Please let me know what will be the issue. thanks.


M
Replied on 16/03/2016

see if this helps

http://stackoverflow.com/questions/7600898/testng-error-cannot-find-class-in-classpath