From: Zhen Z. <zhe...@ho...> - 2008-06-10 15:02:13
|
Hi, I'm wondering if there is a tutorial regarding testing ajax function calls with HTMLUnit. Right now, I'm just simply calling the onclick function ,which calls a A4J.AJAX.Submit(....) function, but got an exception: ======= EXCEPTION START ======== EcmaError: lineNumber=[57] column=[0] lineSource=[null] name=[TypeError] sourceName=[https://localhost/webui/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf] message=[TypeError: Cannot read property "target" from undefined (https://localhost/webui/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf#57)] com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "target" from undefined (https://localhost/webui/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf#57) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:553) at org.mozilla.javascript.Context.call(Context.java:499) at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:468) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:970) at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventHandler(EventListenersContainer.java:166) at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:179) at com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:568) at com.gargoylesoftware.htmlunit.html.HtmlElement$2.run(HtmlElement.java:1202) at org.mozilla.javascript.Context.call(Context.java:499) at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511) at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:1206) at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:143) at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:116) at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:95) at com.hp.ed.htmlunit.ConfigProfile.testAjax(ConfigProfile.java:64) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:130) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "target" from undefined (https://localhost/webui/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf#57) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3535) at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3563) at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3582) at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3595) at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1381) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3054) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2484) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401) at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:192) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:160) at com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHandler.java:100) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:496) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaScriptEngine.java:461) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:549) ... 31 more Enclosed exception: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "target" from undefined (https://localhost/webui/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf#57) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3535) at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3563) at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3582) at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3595) at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1381) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3054) at script(https://15.178.180.33/webui/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf:57) at script(onclick event for HtmlAnchor[<a href="#" id="profileTabForm:tab7:mobileTab:mobileListTable:nameHeader" name="profileTabForm:tab7:mobileTab:mobileListTable:nameHeader" onclick="A4J.AJAX.Submit('_viewRoot','profileTabForm',event,{'eventsQueue':'profileTabForm:tab7:mobileTab:mobileListTable:nameHeader','parameters':{'profileTabForm:tab7:mobileTab:mobileListTable:nameHeader':'profileTabForm:tab7:mobileTab:mobileListTable:nameHeader'} ,'actionUrl':'/webui/admin/configui/profile/profileTab.jsf','oncomplete':function(request,event,data){cwc.Dom.onAjaxComplete('profileTabForm:tab7:mobileTab:mobileListTable');},'ignoreDupResponses':true,'requestDelay':100} );return false;" title="Name">]:1) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2484) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401) at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:192) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:160) at com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHandler.java:100) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:496) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaScriptEngine.java:461) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:549) at org.mozilla.javascript.Context.call(Context.java:499) at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:468) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:970) at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventHandler(EventListenersContainer.java:166) at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:179) at com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:568) at com.gargoylesoftware.htmlunit.html.HtmlElement$2.run(HtmlElement.java:1202) at org.mozilla.javascript.Context.call(Context.java:499) at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511) at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:1206) at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:143) at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:116) at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:95) at com.hp.ed.htmlunit.ConfigProfile.testAjax(ConfigProfile.java:64) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:130) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) == CALLING JAVASCRIPT == function () { [native code, arity=0] } ======= EXCEPTION END ======== thanks jane _________________________________________________________________ |