A JavaScript error occurs when the combination of table.deleteRow() and table.insertRow() is used. The deleteRow statement is nested in a while loop where "table.rows.length > 0" controls the looping. The insertRow statement must have at least 2 rows to insert in order to see the exception. And finally, this will only occur on the 2nd call (onclick events used below) from the page. The first call succeeds.
This scenario makes me think that a variable (an index is what the JavaScript exception mentions briefly below) is not being properly reset. The HTML and webtest script are below. If possible could someone try to reproduce this? If it's a real bug, then let me know where to open it. Thanks, Craig ========== WebTest Output ========= C:\canoo-webtest>bin\webtest.bat -f tests\test1.xml "C:/java/jdk1.5.0_07\bin\java.exe" -Xms64M -Xmx256M -cp "C:\canoo-webtest\bin\.. \lib\ant-launcher.jar" -Dant.library.dir="C:\canoo-webtest\bin\..\lib" org.apach e.tools.ant.launch.Launcher -nouserlib -lib "C:\canoo-webtest\bin\..\lib\build;C :\canoo-webtest\bin\..\lib\build\clover.jar" -f tests\test1.xml Buildfile: tests\test1.xml main: Overriding previous definition of reference to ant.PropertyHelper Overriding previous definition of reference to ant.PropertyHelper BUILD FAILED C:\canoo-webtest\tests\test1.xml:11: Canoo Webtest: R_1408. Test failed. Exception raised: com.canoo.webtest.engine.StepExecutionException: Unexpected ex ception caught: com.gargoylesoftware.htmlunit.ScriptException: Index or size is negative or greater than the allowed amount (index: 1, 0 rows) (Embedded script in http://localhost/test.html#10), Step: SetCheckbox at C:\canoo-webtest\tests\t est1.xml:34: with (taskName="setCheckbox")com.canoo.webtest.engine.StepExecutio nException: Unexpected exception caught: com.gargoylesoftware.htmlunit.ScriptExc eption: Index or size is negative or greater than the allowed amount (index: 1, 0 rows) (Embedded script in http://localhost/test.html#10), Step: SetCheckbox at C:\canoo-webtest\tests\test1.xml:34: with (taskName="setCheckbox") at com.canoo.webtest.steps.Step.handleUnexpectedException(Step.java:427) at com.canoo.webtest.steps.AbstractBrowserAction.handleUnexpectedExcepti on(AbstractBrowserAction.java:120) at com.canoo.webtest.steps.Step.execute(Step.java:115) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at com.canoo.webtest.ant.TestStepSequence.executeSteps(TestStepSequence. java:43) at com.canoo.webtest.ant.TestStepSequence.doExecute(TestStepSequence.jav a:31) at com.canoo.webtest.steps.Step.execute(Step.java:108) at org.apache.tools.ant.Task.perform(Task.java:364) at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:164) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project.java:1185) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe cutor.java:40) at org.apache.tools.ant.Project.executeTargets(Project.java:1068) at org.apache.tools.ant.Main.runBuild(Main.java:668) at org.apache.tools.ant.Main.startAnt(Main.java:187) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) Caused by: com.gargoylesoftware.htmlunit.ScriptException: Index or size is negat ive or greater than the allowed amount (index: 1, 0 rows) (Embedded script in ht tp://localhost/test.html#10) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunctio n(JavaScriptEngine.java:307) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunction IfPossible(HtmlPage.java:737) at com.gargoylesoftware.htmlunit.html.HtmlPage.runEventHandler(HtmlPage. java:1463) at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableEl ement.java:103) at com.canoo.webtest.steps.form.SetCheckbox.setField(SetCheckbox.java:55 ) at com.canoo.webtest.steps.form.AbstractSetFieldStep.doExecute(AbstractS etFieldStep.java:152) at com.canoo.webtest.steps.Step.execute(Step.java:108) ... 19 more Caused by: org.mozilla.javascript.EvaluatorException: Index or size is negative or greater than the allowed amount (index: 1, 0 rows) (Embedded script in http:/ /localhost/test.html#10) at com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.runtimeE rror(StrictErrorReporter.java:114) at org.mozilla.javascript.Context.reportRuntimeError(Context.java:966) at org.mozilla.javascript.Context.reportRuntimeError(Context.java:1022) at com.gargoylesoftware.htmlunit.javascript.host.RowContainer.jsxFunctio n_insertRow(RowContainer.java:152) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:142) at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:405) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:308 4) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.j ava:149) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:3 37) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:275 5) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.j ava:147) at com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(Event Handler.java:95) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunctio n(JavaScriptEngine.java:302) ... 25 more Total time: 2 seconds ================================= ========== WebTest FILE ========= <?xml version="1.0"?> <!DOCTYPE project SYSTEM "WebTest.dtd"[ ]> <project name="Testing 1.2.3" basedir="." default="main"> <property name="webtest.home" location="C:\canoo-webtest"/> <import file="${webtest.home}/lib/taskdef.xml"/> <target name="main"> <webtest name="myTest"> <config host="localhost" port="80" protocol="http" summary="true" saveresponse="true" autorefresh="true" haltonerror="true" haltonfailure="true"/> <steps> <invoke url="test.html"/> <verifyTitle text="Testing"/> <setCheckbox htmlid="myCheckbox" checked="true"/> <verifyXPath xpath="id('myTable')/tbody/tr[2]/td[2]" text="NEW CELL1-1" /> <setCheckbox htmlid="myCheckbox" checked="false"/> <verifyXPath xpath="id('myTable')/tbody/tr[2]/td[2]" text="NEW CELL1-1" /> </steps> </webtest> </target> </project> ================================= =========== HTML FILE =========== <HTML> <HEAD> <TITLE>Testing</TITLE> </HEAD> <BODY> <script language="javascript"> function insertRowToTable() { var tbl = document.getElementById("myTable"); // clear the table (without this, no exception is thrown) while (tbl.rows.length > 0) tbl.deleteRow(0); // repopulate the table for (var i=0; i < 2; i++) { var row = tbl.insertRow(i); //Exception thrown here but only on 2nd loop for (var j=0; j < 2; j++) { var cell = row.insertCell(j); cell.innerHTML = "NEW CELL" + j + "-" + i; } } } </script> <H1>Test</H1> <INPUT TYPE="checkbox" ID="myCheckbox" NAME="myCheckbox" ONCLICK="insertRowToTable()" /> <TABLE ID="myTable" BORDER="1"> </TABLE> <FONT SIZE=-2>Note: ONCLICK event for checkbox above destroys and populates table.<BR> JavaScript Exception in HtmlUnit is thrown on the second click but only when the table.deleteRow() "while loop" is called before. (IE and FF behave correctly.)</FONT> </BODY> </HTML> ================================= __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ WebTest mailing list [email protected] http://lists.canoo.com/mailman/listinfo/webtest

