Selenium Webdriver + Java - Eclipse: java.lang.NoClassDefFoundError

Solution 1:

java.lang.NoClassDefFoundError is observed when the JRE can't find a Class.

In simple words the required imports or jar files are not available. From the snapshot you have shared its pretty much evident that you have tried to add the Java Client related jars.

In this case you need to follow the following steps:

  1. Remove all the jars referring to previous versions of Selenium standalone server & Selenium Java client
  2. Import only the selenium-server-standalone-3.7.0.
  3. In your IDE within Project menu, select the option Build Automatically and execute the Clean option for all of your Projects.
  4. Execute your Test.

Solution 2:

Seems like the latest (v3.7) Selenium-Java zip file contains lesser jars in the lib folder. v3.6 contained 10 lib jars but v3.7 contains only 7 jars.

The missing jar which is causing all the issue for the op is 'httpcore-4.4.6.jar'. I am not sure whether the removal of jar is intentional or not. Maybe chromedriver has catch up with Selenium java 3.7seeing that .

I the mean time use Selenium Java 3.6. Don't forget to add the /lib folder as well.

http://selenium-release.storage.googleapis.com/3.6/selenium-java-3.6.0.zip