From: Marks, D. <Dav...@nr...> - 2015-08-24 12:39:22
|
I figured that was probably at least part of my problem, yeah. After tinkering with it a bit more over the weekend, I managed to load and interact with the webpage via HtmlUnit successfully using this set of options in the WebClient: setThrowExceptionOnScriptError(false); setCssEnabled(false); setThrowExceptionOnFailingStatusCode(false); waitForBackgroundJavaScript(50000); It seems likely only some functionality on the page was loaded successfully, but what I was targeting worked so this is good enough for me. Perhaps this set of options will help someone else in the future. ~David Marks From: Ahmed Ashour <asa...@ya...<mailto:asa...@ya...>> Reply-To: Ahmed Ashour <asa...@ya...<mailto:asa...@ya...>>, "htm...@li...<mailto:htm...@li...>" <htm...@li...<mailto:htm...@li...>> Date: Sunday, August 23, 2015 at 8:52 PM To: "htm...@li...<mailto:htm...@li...>" <htm...@li...<mailto:htm...@li...>> Subject: Re: [Htmlunit-user] Error Accessing Page Hi, VBScript is not supported by HtmlUnit, only JavaScript. Ahmed ________________________________ From: "Marks, David" <Dav...@nr...<mailto:Dav...@nr...>> To: "htm...@li...<mailto:htm...@li...>" <htm...@li...<mailto:htm...@li...>> Sent: Thursday, August 20, 2015 10:30 PM Subject: [Htmlunit-user] Error Accessing Page Hello, I'm a new user to HtmlUnit and am unfortunately receiving an error on the first page I tried to load. I'm not sure if the error lies with me or the page, but here are the details: Code I am trying to execute public void homePage() throws Exception { try (final WebClient webClient = new WebClient()) { final HtmlPage page = webClient.getPage("http://www.ukho.gov.uk/ProductsandServices/MartimeSafety/Pages/NMPublic.aspx"); } catch(Exception e) { e.printStackTrace(); } } It's failing on the getPage call, saying "======= EXCEPTION START ======== Exception class=[net.sourceforge.htmlunit.corejs.javascript.EvaluatorException] com.gargoylesoftware.htmlunit.ScriptException: syntax error (script in http://www.ukho.gov.uk/ProductsandServices/MartimeSafety/Pages/NMPublic.aspx from (714, 460) to (755, 10)#744)" followed by an impressively long stack trace. Lines 714-755 of the page seem to be snippets of code dealing with the browser context and the start of a VBSCRIPT block. Does this page have elements HtmlUnit can't handle currently or is my accessing approach incorrect? Thanks for the help, David Marks |