0

I tried to load simple page using HTMLUnit it is throwing below error

Enclosed exception: 
net.sourceforge.htmlunit.corejs.javascript.EcmaError: ReferenceError: "define" is not defined.

I think this is problem because of ECMA6 ? But I am not able to find any way to resolve

Rahul Shukla
  • 505
  • 7
  • 20

1 Answers1

0

My first attempt would be to ignore all javascript related Exceptions because on most web sites the interesting parts work even if some of the javascript is not executed.

webClient.getOptions().setThrowExceptionOnScriptError(false); // we never want Exceptions because of javascript

Some other properties which are often useful (not directly related to your problem) are:

  • webClient.setJavaScriptTimeout(30000); // limit to e.g.30s
  • webClient.getOptions().setTimeout(300000); // timeout to e.g. 300s = 5min
  • webClient.getOptions().setCssEnabled(false);
  • webClient.getOptions().setPopupBlockerEnabled(true);
  • webClient.setRefreshHandler(new WaitingRefreshHandler(...)); // limit the time for refreshes
MrSmith42
  • 9,961
  • 6
  • 38
  • 49