HttpUnit - org.mozilla.javascript.EcmaError: TypeError: Cannot find function createElement

"Gnanasekaran Sakthivel" <[email protected]> Wed, 14 Jan 2009 18:17:12 -0500
Newsgroups gmane.comp.web.httpunit.devel
Message-ID <[email protected]>
Hi Guys.
I am stuck with this error for about couple days.

org.mozilla.javascript.EcmaError: TypeError: Cannot find function
createElement. (httpunit#418)
    at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3229)
    at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3219)
    at
org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3235)
    at
org.mozilla.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3247)
    at
org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3307)
    at
org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:1991)
    at
org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2932)
    at script.appInfoUserSelections(httpunit:418)
    at script(httpunit)
    at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2251)
    at
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:161)
    at
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:340)
    at
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2758)
    at
org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:172)
    at org.mozilla.javascript.Context.evaluateString(Context.java:1132)
    at
com.meterware.httpunit.javascript.ScriptingEngineImpl.runScript(ScriptingEngineImpl.java:92)
    at
com.meterware.httpunit.scripting.ScriptableDelegate.runScript(ScriptableDelegate.java:88)
    at
com.meterware.httpunit.parsing.NekoDOMParser.runScript(NekoDOMParser.java:151)
    at
com.meterware.httpunit.parsing.ScriptFilter.getTranslatedScript(ScriptFilter.java:150)
    at
com.meterware.httpunit.parsing.ScriptFilter.endElement(ScriptFilter.java:131)
    at
org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:249)
    at
org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:367)
    at
org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1015)
    at
org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:888)
    at
org.cyberneko.html.HTMLScanner$SpecialScanner.scan(HTMLScanner.java:2831)
    at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:809)
    at
org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:478)
    at
org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:431)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at
com.meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.java:48)
    at com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:271)
    at
com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:1301)
    at com.meterware.httpunit.WebResponse.getFrames(WebResponse.java:1285)
    at
com.meterware.httpunit.WebResponse.getFrameRequests(WebResponse.java:1024)
    at com.meterware.httpunit.FrameHolder.updateFrames(FrameHolder.java:179)
    at
com.meterware.httpunit.WebWindow.updateFrameContents(WebWindow.java:315)
    at
com.meterware.httpunit.WebClient.updateFrameContents(WebClient.java:526)
    at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:201)
    at
com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183)
    at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158)
    at com.meterware.httpunit.WebWindow.sendRequest(WebWindow.java:134)
    at
com.meterware.httpunit.WebRequestSource.submitRequest(WebRequestSource.java:297)
    at
com.meterware.httpunit.WebRequestSource.submitRequest(WebRequestSource.java:253)
    at com.meterware.httpunit.WebForm.submitRequest(WebForm.java:127)
    at com.meterware.httpunit.WebForm.doFormSubmit(WebForm.java:143)
    at
com.meterware.httpunit.SubmitButton.doButtonAction(SubmitButton.java:69)
    at com.meterware.httpunit.Button.doOnClickSequence(Button.java:91)
    at com.meterware.httpunit.WebForm.submit(WebForm.java:107)
    at com.meterware.httpunit.WebForm.submit(WebForm.java:93)
    at com.meterware.httpunit.WebForm.submit(WebForm.java:82)
    at
test.applicant.ApplicantCreateTest.testApplicantCreate(ApplicantCreateTest.java:52)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    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:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
    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)
com.meterware.httpunit.ScriptException: Script 'appInfoUserSelections()'
failed: org.mozilla.javascript.EcmaError: TypeError: Cannot find function
createElement. (httpunit#418)

Our JSPs have pretty good bunch of java scripts. In this particular case, I
have a JSP including another jsp. This included JSP has few scripts, some of
them are triggered on body onload event.
Now, when I get to this page response through HttpUnit, I am getting this
exception.

The script extract:
function appInfoUserSelections()
{
------
var element = document.createElement("option");
-----
}

This line is throwing this exception. Now initially I thought, may be the
javascript *document* does not exist or it refers to something else, since
it is an included page.* *However, even after, I included this second JSP
directly into the main JSP, same Exception is thrown.
*document*createElement method has been introduced in DOM level 1, IE
and Mozilla
supports it. I am kind of confused. Ours was a completely developed
application with lots of version went onto production. I am just trying to
start this testing thing on top of it. I could succesfully make user login
test. This is my first functional use case.

Downloaded HttpUnit a month ago, using Eclipse 3.2 IDE, created TestCases
through this; I have the following jars in the testing project library:
junit3.8.1.jar, httpunit.jar, js-1.6R5.jar, nekhohtml-0.9.5.jar,
xercesImpl-2.6.1.jar, xmlParserAPIs-2.6.1.jar. Out of which junit3.8.1.jar
comes with Eclipse testing plugins itself I believe.

Someone please help me.

-- 
Good day

(Edison Paul) Gnanasekaran Sakthivel

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword

_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop