1

I don't know how to fix this problem... Will you help me please?

I get this exeption: Exception in thread "main" java.lang.NoClassDefFoundError: etc.

My code is:

package mainsrc;

import com.gargoylesoftware.htmlunit.WebClient;

 public void search () throws Exception {

WebClient wb = new WebClient (); }

Curratos
  • 27
  • 3
  • have you looked into what typically causes a `java.lang.NoClassDefFoundError`? – NG. Oct 26 '13 at 21:13
  • Yes I've, but I still can't figure out whats wrong. Aint a professional. – Curratos Oct 27 '13 at 17:35
  • You haven't setup HTMLUnit properly. Check this question [How to setup HtmlUnit in an Eclipse project?](http://stackoverflow.com/questions/9096433/how-to-setup-htmlunit-in-an-eclipse-project) – Mosty Mostacho Oct 27 '13 at 21:28

1 Answers1

0

I think you should better use selenium-firefox-driver-2.0a5.jar and imitate the Firefox browser as in the following code fragment. You may use chrome also.

Use the following imports and select a web browser and furthermore you have to use selenium-server-standalone-2.44.0.jar or above versions

import com.gargoylesoftware.htmlunit.WebClient;//you already use this
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.html.*;

WebClient webClient = new WebClient(BrowserVersion.FIREFOX_24);
HtmlPage page = (HtmlPage) webClient.getPage("Page url");