From: David D. K. <ddk...@ki...> - 2005-06-09 05:20:49
|
HtmlUnit threw an exception while attempting to run the JavaScript on the test page. It failed trying to access the "document" property of some object (like window.document?) because "window" (or whatever variable you used) was not defined. It would be helpful if you could post the JavaScript being excecuted (with some context), or a reduced test case. Dave On Jun 8, 2005, at 6:28 PM, Ulaszek, Ryan wrote: > Hello, > > I am trying to load a web site with this code > > final WebClient webClient = new WebClient(); > final URL url = new URL("http://localhost/webv2/html/ > testapp.htm"); > > // Get the first page > final HtmlPage page1 = (HtmlPage)webClient.getPage(url); > > And I get this exeception. Any ideas? > > ======= EXCEPTION START ======== > EcmaError: lineNumber=[10] column=[0] lineSource=[null] name= > [TypeError] sourceName=[Embedded script] message=[TypeError: Cannot > read property "document" from undefined (Embedded script#10)] > > com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot > read property "document" from undefined (Embedded script#10) > > at > com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction > (JavaScriptEngine.java:340) > at > com.gargoylesoftware.htmlunit.html.HtmlPage.executeOnLoadHandlersIfNee > ded(HtmlPage.java:963) > at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize > (HtmlPage.java:158) > at > com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto > (WebClient.java:716) > at com.gargoylesoftware.htmlunit.WebClient.getPage > (WebClient.java:376) > at com.gargoylesoftware.htmlunit.WebClient.getPage > (WebClient.java:415) > at HtmlTest.testHomePage(HtmlTest.java:38) > at HtmlTest.main(HtmlTest.java:26) > Enclosed exception: > org.mozilla.javascript.EcmaError: TypeError: Cannot read property > "document" from undefined (Embedded script#10) > at org.mozilla.javascript.ScriptRuntime.constructError > (ScriptRuntime.java:3240) > at org.mozilla.javascript.ScriptRuntime.constructError > (ScriptRuntime.java:3230) > at org.mozilla.javascript.ScriptRuntime.typeError > (ScriptRuntime.java:3246) > at org.mozilla.javascript.ScriptRuntime.typeError2 > (ScriptRuntime.java:3265) > at org.mozilla.javascript.ScriptRuntime.undefReadError > (ScriptRuntime.java:3278) > at org.mozilla.javascript.ScriptRuntime.getObjectProp > (ScriptRuntime.java:1319) > at org.mozilla.javascript.Interpreter.interpret > (Interpreter.java:2744) > at org.mozilla.javascript.Interpreter.interpret > (Interpreter.java:2164) > at org.mozilla.javascript.InterpretedFunction.call > (InterpretedFunction.java:140) > at org.mozilla.javascript.ContextFactory.doTopCall > (ContextFactory.java:304) > at org.mozilla.javascript.ScriptRuntime.doTopCall > (ScriptRuntime.java:2769) > at org.mozilla.javascript.Interpreter.interpret > (Interpreter.java:2145) > at org.mozilla.javascript.InterpretedFunction.call > (InterpretedFunction.java:140) > at > com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call > (EventHandler.java:88) > at > com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction > (JavaScriptEngine.java:335) > at > com.gargoylesoftware.htmlunit.html.HtmlPage.executeOnLoadHandlersIfNee > ded(HtmlPage.java:963) > at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize > (HtmlPage.java:158) > at > com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto > (WebClient.java:716) > at com.gargoylesoftware.htmlunit.WebClient.getPage > (WebClient.java:376) > at com.gargoylesoftware.htmlunit.WebClient.getPage > (WebClient.java:415) > at HtmlTest.testHomePage(HtmlTest.java:38) > at HtmlTest.main(HtmlTest.java:26) > == CALLING JAVASCRIPT == > > Ryan Ulaszek | QA Software Automation Engineer: | Intuit, Inc. > 858-525-9560 > |