From: Zhenrong L. <Zhe...@sa...> - 2005-03-15 19:11:42
|
Hey, I have a test case which will test invalid text input: after enter an = invalid value in the text input, then click run button, an alert will = show up and after you click OK in the alert wondow, the focus will go = back to the input text field for new input.=20 .... final HtmlPage page3 =3D (HtmlPage)input.click(); assertEquals(handler.getCollectedAlerts().size(), 1); .... The test passed the assertEquals(), but I got JavaScriptException from = console: =3D=3D>> JavaScriptEngine, JavaScriptException occurred:=20 =3D=3D=3D=3D=3D=3D=3D EXCEPTION START =3D=3D=3D=3D=3D=3D=3D=3D EcmaError: lineNumber=3D[1] column=3D[0] = lineSource=3D[GargoyleWrapper2()] name=3D[TypeError] sourceName=3D[)] = message=3D[TypeError: focus is not a function. ()#1)] com.gargoylesoftware.htmlunit.ScriptException: TypeError: focus is not a = function. ()#1) at = com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScr= iptEngine.java:310) at = com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(H= tmlPage.java:709) at = com.gargoylesoftware.htmlunit.javascript.host.Window$1.run(Window.java:27= 4) at java.lang.Thread.run(Unknown Source) Enclosed exception:=20 org.mozilla.javascript.EcmaError: TypeError: focus is not a function. = ()#1) at = org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:32= 40) at = org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:32= 30) at = org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3246) at = org.mozilla.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3258) at = org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:= 3317) at = org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime= .java:1987) at = org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:114= ) at org.mozilla.javascript.gen.c16._c1(Wrapper definition for = Window.setTimeout():1) at org.mozilla.javascript.gen.c16.call(Wrapper definition for = Window.setTimeout()) at = org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:105= ) at org.mozilla.javascript.gen.c17._c0(Window.setTimeout():1) at org.mozilla.javascript.gen.c17.call(Window.setTimeout()) at = org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:304) at = org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2769) at org.mozilla.javascript.gen.c17.call(Window.setTimeout()) at org.mozilla.javascript.gen.c17.exec(Window.setTimeout()) at org.mozilla.javascript.Context.evaluateString(Context.java:1220) at = com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScr= iptEngine.java:304) at = com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(H= tmlPage.java:709) at = com.gargoylesoftware.htmlunit.javascript.host.Window$1.run(Window.java:27= 4) at java.lang.Thread.run(Unknown Source) =3D=3D CALLING JAVASCRIPT =3D=3D GargoyleWrapper2() =3D=3D=3D=3D=3D=3D=3D EXCEPTION END =3D=3D=3D=3D=3D=3D=3D=3D Mar 15, 2005 1:48:17 PM = com.gargoylesoftware.htmlunit.javascript.host.Window$1 run SEVERE: Caught exception in Window.setTimeout() =3D=3D=3D=3D=3D=3D=3D EXCEPTION START =3D=3D=3D=3D=3D=3D=3D=3D EcmaError: lineNumber=3D[1] column=3D[0] = lineSource=3D[GargoyleWrapper2()] name=3D[TypeError] sourceName=3D[)] = message=3D[TypeError: focus is not a function. ()#1)] com.gargoylesoftware.htmlunit.ScriptException: TypeError: focus is not a = function. ()#1) at = com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScr= iptEngine.java:310) at = com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(H= tmlPage.java:709) at = com.gargoylesoftware.htmlunit.javascript.host.Window$1.run(Window.java:27= 4) at java.lang.Thread.run(Unknown Source) Enclosed exception:=20 org.mozilla.javascript.EcmaError: TypeError: focus is not a function. = ()#1) at = org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:32= 40) at = org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:32= 30) at = org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3246) at = org.mozilla.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3258) at = org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:= 3317) at = org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime= .java:1987) at = org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:114= ) at org.mozilla.javascript.gen.c16._c1(Wrapper definition for = Window.setTimeout():1) at org.mozilla.javascript.gen.c16.call(Wrapper definition for = Window.setTimeout()) at = org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:105= ) at org.mozilla.javascript.gen.c17._c0(Window.setTimeout():1) at org.mozilla.javascript.gen.c17.call(Window.setTimeout()) at = org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:304) at = org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2769) at org.mozilla.javascript.gen.c17.call(Window.setTimeout()) at org.mozilla.javascript.gen.c17.exec(Window.setTimeout()) at org.mozilla.javascript.Context.evaluateString(Context.java:1220) at = com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScr= iptEngine.java:304) at = com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(H= tmlPage.java:709) at = com.gargoylesoftware.htmlunit.javascript.host.Window$1.run(Window.java:27= 4) at java.lang.Thread.run(Unknown Source) =3D=3D CALLING JAVASCRIPT =3D=3D GargoyleWrapper2() =3D=3D=3D=3D=3D=3D=3D EXCEPTION END =3D=3D=3D=3D=3D=3D=3D=3D I checked the JavaScript and I believe the offfending code is: if (maxValue !=3D null && elementValue.length !=3D 0 && elementValue > = maxValue) { = alert(SAS_substituteL10N(dynamicPP_validate_msg16,elementName,maxValue,ma= xValExclusiveMessage)); showContent(theObject.menuItemName, theObject.menuItemName, = theObject.contentElementName); window.setTimeout("formElement.focus();", 400); return true; } But I don't have a clue how to fix this and I was wondering if someone = can shed some light? Thanks, -Zhenrong |