zeyad - 2006-05-10

I have problem in HttpUnit when i ues javaScript function that iterat array [] using length keyword as this example:

for(i=0;i<keywordsField.options.length;i++){
        if(keywordsField.options[i].value==id){
            keywordsField.options[i].selected=true;
        }else{
            keywordsField.options[i].selected=false;
        }   
    }

the error is :
----------
java.lang.RuntimeException: Event 'openListDialog('MULTI_VIEW_LIST_DIALOG', 'PHASE_DIALOG', 'PHASE_DIALOG_ASSIGN_TO','','-1','PHASE_DIALOG_ASSIGN_TO',7);' failed: org.mozilla.javascript.JavaScriptException: java.lang.RuntimeException: Script '//code to use multi value dialog var dialog = new MultiValueDialog(document.forms[0].DIALOG_KEYWORDS , opener.document.forms[0].elements[webFieldName],opener.document); //to get values from source document use dialog.loadValues();' failed: java.lang.ArrayIndexOutOfBoundsException: -1 at com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.handleScriptException(JavaScript.java:189) at com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.performEvent(JavaScript.java:165) at com.meterware.httpunit.scripting.ScriptableDelegate.doEvent(ScriptableDelegate.java:55) at com.meterware.httpunit.WebRequestSource.submitRequest(WebRequestSource.java:224) at com.meterware.httpunit.WebLink.click(WebLink.java:90) at net.sourceforge.jwebunit.HttpUnitDialog.submitRequest(HttpUnitDialog.java:592) at net.sourceforge.jwebunit.HttpUnitDialog.clickLink(HttpUnitDialog.java:772) at net.sourceforge.jwebunit.WebTester.clickLink(WebTester.java:938) at com.exoftware.exactor.command.web.ClickLink.execute(ClickLink.java:59) at com.exoftware.exactor.Script.execute(Script.java:229) at com.exoftware.exactor.ExecutionSet.execute(ExecutionSet.java:120) at com.exoftware.exactor.Runner.run(Runner.java:126) at com.exoftware.exactor.Runner.main(Runner.java:78) java.lang.RuntimeException: java.lang.RuntimeException: Event 'openListDialog('MULTI_VIEW_LIST_DIALOG', 'PHASE_DIALOG', 'PHASE_DIALOG_ASSIGN_TO','','-1','PHASE_DIALOG_ASSIGN_TO',7);' failed: org.mozilla.javascript.JavaScriptException: java.lang.RuntimeException: Script '//code to use multi value dialog var dialog = new MultiValueDialog(document.forms[0].DIALOG_KEYWORDS , opener.document.forms[0].elements[webFieldName],opener.document); //to get values from source document use dialog.loadValues();' failed: java.lang.ArrayIndexOutOfBoundsException: -1 at com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.handleScriptException(JavaScript.java:189) at com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.performEvent(JavaScript.java:165) at com.meterware.httpunit.scripting.ScriptableDelegate.doEvent(ScriptableDelegate.java:55) at com.meterware.httpunit.WebRequestSource.submitRequest(WebRequestSource.java:224) at com.meterware.httpunit.WebLink.click(WebLink.java:90) at net.sourceforge.jwebunit.HttpUnitDialog.submitRequest(HttpUnitDialog.java:592) at net.sourceforge.jwebunit.HttpUnitDialog.clickLink(HttpUnitDialog.java:772) at net.sourceforge.jwebunit.WebTester.clickLink(WebTester.java:938) at com.exoftware.exactor.command.web.ClickLink.execute(ClickLink.java:59) at com.exoftware.exactor.Script.execute(Script.java:229) at com.exoftware.exactor.ExecutionSet.execute(ExecutionSet.java:120) at com.exoftware.exactor.Runner.run(Runner.java:126) at com.exoftware.exactor.Runner.main(Runner.java:78) at net.sourceforge.jwebunit.HttpUnitDialog.submitRequest(HttpUnitDialog.java:595) at net.sourceforge.jwebunit.HttpUnitDialog.clickLink(HttpUnitDialog.java:772) at net.sourceforge.jwebunit.WebTester.clickLink(WebTester.java:938) at com.exoftware.exactor.command.web.ClickLink.execute(ClickLink.java:59) at com.exoftware.exactor.Script.execute(Script.java:229) at com.exoftware.exactor.ExecutionSet.execute(ExecutionSet.java:120) at com.exoftware.exactor.Runner.run(Runner.java:126) at com.exoftware.exactor.Runner.main(Runner.java:78)
-------------------------------