Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Cannot find function 'item' in object

Help
2009-06-04
2013-04-26
  • Venkata Ramana
    Venkata Ramana
    2009-06-04

    Hello,
    I  am using the httpunit-1.7 version and js-1.6R5 version for testing my screens
    one of my javscript function having the following code while executing this function i am getting following error, please anybody help me on this

    javascript code is:
    for (i=0; i<document.frmProject.elements.length; i++)
                {
                    var theObject = document.frmProject.elements.item(i);
                    strName = document.frmProject.elements.item(i).name;
                    if ((theObject.type =='text') && (theObject.value =='') && (theObject.attributes.validationmsg))
                    {
                        errors = errors + ' - ' + theObject.attributes.validationmsg.value.replace('_', ' ') + '\n';       
            }
    error is :

    org.mozilla.javascript.EcmaError: TypeError: Cannot find function item in object [object ElementArray]. (httpunit#12)
        at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654)
        at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3632)
        at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3660)
        at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3679)
        at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3743)
        at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2247)
        at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2214)
        at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3143)
        at script.checkForm(httpunit:12)
        at script.x(httpunit)
        at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2487)
        at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
        at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
        at com.meterware.httpunit.javascript.ScriptingEngineImpl.doEventScript(ScriptingEngineImpl.java:131)
        at com.meterware.httpunit.scripting.ScriptableDelegate.doEventScript(ScriptableDelegate.java:70)
        at com.meterware.httpunit.HTMLElementScriptable.handleEvent(HTMLElementScriptable.java:95)
        at com.meterware.httpunit.HTMLElementBase.handleEvent(HTMLElementBase.java:94)
        at com.meterware.httpunit.FormControl.doOnClickEvent(FormControl.java:299)
        at com.meterware.httpunit.Button.doOnClickSequence(Button.java:89)
        at com.meterware.httpunit.Button.click(Button.java:102)
        at nl.sogeti.einstein.webforms.httpunit.WebformsHttpunitTest.testSaveProjectRegistration(WebformsHttpunitTest.java:1288)
        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:154)