Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HtmlUnit ignore JavaScript errors?

I'm trying to traverse through a website but on one of their pages I get this error:

EcmaError: lineNumber=[671] column=[0] lineSource=[null] name=[TypeError] sourceName=[https://reservations.besodelsolresort.com/asp/CalendarPopup.js] message=[TypeError: Cannot read property "parentNode" from undefined (https://reservations.besodelsolresort.com/asp/CalendarPopup.js#671)]
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "parentNode" from undefined (https://reservations.besodelsolresort.com/asp/CalendarPopup.js#671)

Is there anyway I can just ignore this error? I don't particularly care if the calendar loads properly.

like image 445
cantread Avatar asked Jan 22 '14 21:01

cantread


1 Answers

Alexey's answer is for HttpUnit. For HtmlUnit the code is similar

WebClient client = new WebClient();
client.getOptions().setThrowExceptionOnScriptError(false);
like image 79
Matthew Molloy Avatar answered Sep 22 '22 09:09

Matthew Molloy