From: <Ale...@ag...> - 2005-06-30 10:45:40
|
Hello I get the following exception, while executing the following testcase. The exception occurs after final HtmlPage page2 = (HtmlPage)button.click(); Just an idea: Is the access of attributes of the style JavaScript object not supported ? I attach the javascript module menu_.js ======= test case ======== public static void main(String[] args) throws Exception { // Internet Explorer 6.0.* final BrowserVersion browserVersion = 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 = new WebClient(browserVersion); final URL url = new URL(START_URL); final HtmlPage page1 = (HtmlPage)webClient.getPage(url); final HtmlForm form = page1.getFormByName("logonform"); final HtmlTextInput textField = (HtmlTextInput)form.getInputByName("userId"); // Change the value of the text field textField.setValueAttribute(USER_ID); final HtmlPasswordInput password = (HtmlPasswordInput)form.getInputByName("password"); password.setValueAttribute(PASSWORD); final HtmlButton button = (HtmlButton)form.getButtonsByName("submitButton").get(0); // Now submit the form by clicking the button and get back the // second page. final HtmlPage page2 = (HtmlPage)button.click(); System.out.println(page2.asXml()); ... } ======= EXCEPTION START ======== EcmaError: lineNumber=[530] column=[0] lineSource=[null] name=[TypeError] sourceName=[templates/js/menu_.js] message=[TypeError: Cannot read 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(JavaS criptEngine.java:304) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossi ble(HtmlPage.java:758) at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.j ava:108) at Test.main(Test.java:60) Enclosed exception: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "0" from undefined (templates/js/menu_.js#530) 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.getObjectIndex(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(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(JavaS criptEngine.java:299) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossi ble(HtmlPage.java:758) at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.j ava:108) at Test.main(Test.java:60) == CALLING JAVASCRIPT == function () { [native code, arity=0] } ======= EXCEPTION END ======== -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.8.0/27 - Release Date: 23.06.2005 |