From: David D. K. <ddk...@ki...> - 2005-07-02 19:49:10
|
Try to create a reduced test case that fails, then post a bug. Line =20 530 from the attached menu.js file doesn't look like it matches up =20 with the error message below, though: snObj =3D document.getElementById('submenu-'+mid); Looking at the source for =20 com.gargoylesoft.htmlunit.javascript.host.Style, I would say that =20 access to attributes is possible, although I've never used this =20 feature myself. Dave On Jun 30, 2005, at 5:44 AM, P=F6ppl Alexander wrote: > Hello > > I get the following exception, while executing the following =20 > testcase. The > exception occurs after > final HtmlPage page2 =3D (HtmlPage)button.click(); > > Just an idea: Is the access of attributes of the style JavaScript =20 > object not > supported ? > > I attach the javascript module menu_.js > > =3D=3D=3D=3D=3D=3D=3D test case =3D=3D=3D=3D=3D=3D=3D=3D > public static void main(String[] args) throws Exception { > // Internet Explorer 6.0.* > final BrowserVersion browserVersion =3D new > BrowserVersion("Microsoft Internet Explorer", > "4.0 (compatible; MSIE 6.0; Windows > NT 5.1; SV1; .NET CLR 1.1.4322)", > "Mozilla/4.0 (compatible; MSIE 6.0; > Windows NT 5.1; SV1; .NET CLR 1.1.4322)", "1.2", 6F); > final WebClient webClient =3D new WebClient(browserVersion); > final URL url =3D new URL(START_URL); > final HtmlPage page1 =3D (HtmlPage)webClient.getPage(url); > > final HtmlForm form =3D page1.getFormByName("logonform"); > final HtmlTextInput textField =3D > (HtmlTextInput)form.getInputByName("userId"); > // Change the value of the text field > textField.setValueAttribute(USER_ID); > > final HtmlPasswordInput password =3D > (HtmlPasswordInput)form.getInputByName("password"); > password.setValueAttribute(PASSWORD); > > final HtmlButton button =3D > (HtmlButton)form.getButtonsByName("submitButton").get(0); > > // Now submit the form by clicking the button and get back > the > // second page. > final HtmlPage page2 =3D (HtmlPage)button.click(); > > System.out.println(page2.asXml()); > > ... > } > > =3D=3D=3D=3D=3D=3D=3D EXCEPTION START =3D=3D=3D=3D=3D=3D=3D=3D > EcmaError: lineNumber=3D[530] column=3D[0] lineSource=3D[null] name=3D=20= > [TypeError] > sourceName=3D[templates/js/menu_.js] message=3D[TypeError: Cannot read = =20 > property > "0" from undefined (templates/js/menu_.js#530)] > com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read > property "0" from undefined (templates/js/menu_.js#530) > at > com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction=20= > (JavaS > criptEngine.java:304) > at > com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionI=20= > fPossi > ble(HtmlPage.java:758) > at > com.gargoylesoftware.htmlunit.html.ClickableElement.click=20 > (ClickableElement.j > ava:108) > at Test.main(Test.java:60) > Enclosed exception: > org.mozilla.javascript.EcmaError: TypeError: Cannot read property =20 > "0" from > undefined (templates/js/menu_.js#530) > at > org.mozilla.javascript.ScriptRuntime.constructError=20 > (ScriptRuntime.java:3240) > at > org.mozilla.javascript.ScriptRuntime.constructError=20 > (ScriptRuntime.java:3230) > at > org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:=20 > 3246) > at > org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:=20 > 3265) > at > org.mozilla.javascript.ScriptRuntime.undefReadError=20 > (ScriptRuntime.java:3278) > at > org.mozilla.javascript.ScriptRuntime.getObjectIndex=20 > (ScriptRuntime.java:1349) > at > org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2777) > at > org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2164) > at > org.mozilla.javascript.InterpretedFunction.call=20 > (InterpretedFunction.java:140 > ) > at > org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:=20= > 304) > at > org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:=20 > 2769) > at > org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2145) > at > org.mozilla.javascript.InterpretedFunction.call=20 > (InterpretedFunction.java:140 > ) > at > com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call=20 > (EventHandler > .java:88) > at > com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction=20= > (JavaS > criptEngine.java:299) > at > com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionI=20= > fPossi > ble(HtmlPage.java:758) > at > com.gargoylesoftware.htmlunit.html.ClickableElement.click=20 > (ClickableElement.j > ava:108) > at Test.main(Test.java:60) > =3D=3D CALLING JAVASCRIPT =3D=3D > function () { > [native code, arity=3D0] > } > > =3D=3D=3D=3D=3D=3D=3D EXCEPTION END =3D=3D=3D=3D=3D=3D=3D=3D > > --=20 > No virus found in this outgoing message. > Checked by AVG Anti-Virus. > Version: 7.0.323 / Virus Database: 267.8.0/27 - Release Date: =20 > 23.06.2005 > > > > > <menu_.js> > |